詹金斯 - 使用主动选择和主动选择反应性参数时无法获得所需的选项
我们需要从Jenkins UI中选择环境以运行功能文件。
不同的环境选项:QA,UAT,
基于下拉下的环境选择,所有可用的租户,即与该环境相关的不同服务器。
为了实现上述目的,我将“主动选择参数”用于环境。
- 名称:“环境”
- groovy脚本:返回['qa','uat']
- sublack脚本:返回['错误']
- 选择类型:单个选择
以根据环境选择选择服务器或租户,我使用过”主动选择反应性参数“
- 名称:租户
- groovy脚本:
return ['http://node-1.nginx.portal.daa-1.can.qa.aws.abc.net/login':'CAN','http://node-1.nginx.portal.daa-1.wan.qa.aws.abc.net/login':'WAN']
} else if (Environment.equals("UAT")) {
return ['https://can.uat.daa.app/login':'CANUAT','https://blic.uat.daa.app/login':'BLIC']
}
else if (Environment.equals("PROD")){
return ['http://node-1.nginx.portal.daa-1.can.qa.aws.abc.net/login':'CANPROD','http://node-1.nginx.portal.daa-1.blic.qa.aws.abc.net/login':'BLIC']
} else {
return ["Unknown"]
}
- 后备脚本:return [error']
- 选择类型:应用和保存此配置后单个选择类型
,我在租户下拉下的错误。 似乎犯了一个小错误,但无法捕获它。
We have requirement to select Environment from Jenkins UI to run the feature files.
Different Environment Options: QA, UAT, PROD
On the basis of the Environment selection from drop-down, all the available tenants i.e. different servers associated with that Environment should be visible.
To achieve above purpose I've used "Active Choices Parameter" for Environment.
- Name: "Environment"
- Groovy Script: return ['QA','UAT']
- Fallback Script: return['error']
- Choice Type: Single Select
To select the server or tenant on the basis of Environment selection, I've used "Active Choices Reactive Parameter"
- Name: Tenants
- Groovy Script:
return ['http://node-1.nginx.portal.daa-1.can.qa.aws.abc.net/login':'CAN','http://node-1.nginx.portal.daa-1.wan.qa.aws.abc.net/login':'WAN']
} else if (Environment.equals("UAT")) {
return ['https://can.uat.daa.app/login':'CANUAT','https://blic.uat.daa.app/login':'BLIC']
}
else if (Environment.equals("PROD")){
return ['http://node-1.nginx.portal.daa-1.can.qa.aws.abc.net/login':'CANPROD','http://node-1.nginx.portal.daa-1.blic.qa.aws.abc.net/login':'BLIC']
} else {
return ["Unknown"]
}
- Fallback Script: return['error']
- Choice Type: Single Select
After applying and saving this configuration, I'm getting ERROR in the Tenants drop-down.
Seems making minor mistake but unable to catch it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
环境应在groovy脚本中以“ $”(如
$ noveruction
中的$环境中)提供,以表示它是一个变量。
您是否在活动选择中将“引用参数”指定为“环境”反应性参数设置?:
您可以在脚本控制台中http:// your-jenkins/script在脚本控制台中测试您的groovy脚本
Environment should be prefaced with a '$' (as in
$Environment
) in the groovy script to signify it is a variable.And did you specify the 'Referenced parameters' as 'Environment' in the Active Choices Reactive Parameter settings?:
You can test out your groovy script in the script console at http://your-jenkins-server/script