0
我正在爲Jenkins插件拼湊一些spock測試,並且一路上我想檢查構建變量匹配一些有效的變量之一。這些來自MatrixProject如何測試散列是一個有效的集合?
但我該怎麼做?
我有這個,但它看起來有點笨重,但確實工作
gen_build.getRuns.every(){
it.getBuildVariables().equals([axis1: 'textz', axis2: 'text1']) ||
it.getBuildVariables().equals([axis1: 'textz', axis2: 'text2']) ||
it.getBuildVariables().equals([axis1: 'texty', axis2: 'text2'])
}
編輯這對詹金斯作業DSL矩陣工作插件斯波克規範,我想有用的測試爲
def 'CombinationFilter'() {
given:
def job = configure($/
job(type:MatrixJob){
name "generated"
axis{
text("axis1", ["textz", "texty"])
text("axis2", ["text1", "text2"])
}
steps{
shell('return 255')
}
combinationFilter("axis1=='textz' || axis2=='text2'")
sequential(false)
}
/$)
when:
def job_build = job.scheduleBuild2(0).get()
def gen = rule.getInstance().getItem("generated")
def gen_build = gen.scheduleBuild2(0).get()
def gen_runs = gen_build.getRuns()
then:
job_build.logFile.text.contains("SUCCESS")
gen_build.logFile.text.contains("FAILURE")
gen_runs.every(){it.logFile.text.contains("FAILURE")}
gen_runs.every(){it.getBuildVariables().equals([axis1: 'textz', axis2: 'text1']) || it.getBuildVariables().equals([axis1: 'textz', axis2: 'text2']) || it.getBuildVariables().equals([axis1: 'texty', axis2: 'text2'])}
gen_runs.size() == 3
}