Jenkins

时间:2016-03-28 13:08:19

标签: jenkins groovy

jenkins 参数化作业

定义了两个属性

  1. 选择类型的Property1(具有不同的配置)
  2. 具有多选的扩展选择的Property2,选择值作为Groovy脚本的源(每个配置具有不同测试套件的列表)。参考this jenkins插件。
  3. 想要根据为Property1选择的值在Property2中显示不同的值列表。

    尝试在Property2的Groovy脚本中访问Property1$Property1%Property1%。但是,似乎没有用。

    脚本看起来像下面的

    if ($Property1 == 'configuration1') {
        return ['suite1','suite2', 'suite3']
    } else if ($Property1 == 'configuration2') {
        return ['suite3', 'suite4']
    } else if ($Property1 == 'configuration3') {
        return ['suite5', 'suite6']
    }
    

    即使将简单列表返回到Property2也似乎无法使用像return ['suite1', 'suite2']这样的Groovy脚本(只是尝试显示值列表而不检查条件)。我错过了什么吗?

1 个答案:

答案 0 :(得分:2)

您可以尝试Jenkins Active Choices plugin。参数选项可以从Groovy脚本动态生成,并可以响应其他作业参数的更改。

enter image description here