说,我想在Jenkins中进行参数化测试,该测试获得了从外部代码(例如,在Python中)提供的选择。外部代码位于在测试过程中加载的docker映像上。自然,更新的参数将可用于下一次测试。
即使在测试之后(块阶段),块流水线和参数中的标准解决方案也不起作用,因为常规变量不会在块中更新。我想,无论块“ parameters”的确切位置如何,该块都是作为管道块的开始执行的。
我们创建了一个参数更新阶段,其中脚本在环境变量中提供数据,然后实例化控件,例如:
stage('Update of wizard') {
steps {
container('the-container') {
script {
sh """
python script.py>results.txt
"""
# instantiation of controls
def CHOICE_Stage = choice(choices: ['mirror','develop'],
description: 'Stage',
name: 'Stage')
def RESULT_CHOICES=readFile("testset_results.txt")
CHOICE_AdvancedChoice = new com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition(
"Advanced",
"PT_SINGLE_SELECT",
RESULT_CHOICES,
null,//project name
null,
null,
null,
null,// bindings
null,
null, // propertykey
"A", //default value
null,
null,
null,
null, //default bindings
null,
null,
null, //descriptionPropertyValue
null,
null,
null,
null,
null,
null,
null,// javascript file
null, // javascript
false, // save json param to file
false, // quote
5, // visible item count
"Select testset to execute",
","
)
params << CHOICE_Stage << CHOICE_AdvancedChoice
props << parameters(params)
properties(props)
}
}
}
}
是否可以使用标准参数块而不是阶段块? 您知道该问题有什么更好的解决方案吗?