Jenkins Active Choices 参数插件未按预期工作

Dam*_*men 2 groovy jenkins jenkins-plugins

我有一个hidden parameter叫. 我想根据参数显示选择。我创建了以下常规脚本,但它不起作用JenkinsplatformTypeplatformType

if (platformType.equals("android")) {
  return ['7.0', '6.0']
} else (platformType.equals("ios")) {
  return ['10.0', '9.0']
}
Run Code Online (Sandbox Code Playgroud)

请看下面的截图 在此输入图像描述

dag*_*ett 8

非常确定您没有将 指定platformType为参数,platformVersion或者您的代码中有其他错误。

如果没有错误处理,你只是看不到它。

在你的脚本中你可以捕获这样的异常:

try {
    if (platformType.equals("android")) {
        return ['7.0', '6.0']
    } else if(platformType.equals("ios")) {
        return ['10.0', '9.0']
    }
}catch(e){ return [e.toString()] }
Run Code Online (Sandbox Code Playgroud)

在这种情况下,您会在选择字段中看到错误

  • 使用“Active Choices Reactive Parameter”并为其指定“Referenced parameters = platformType” (2认同)