詹金斯 - 使用主动选择和主动选择反应性参数时无法获得所需的选项

发布于 2025-01-17 17:30:23 字数 1066 浏览 2 评论 0原文

我们需要从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.

Getting ERROR in the drop-down of Tenant Option

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你对谁都笑 2025-01-24 17:30:23

环境应在groovy脚本中以“ $”(如$ noveruction中的$环境中)提供,以表示它是一个变量。

您是否在活动选择中将“引用参数”指定为“环境”反应性参数设置?:

referencedParameters: 'Environment',

您可以在脚本控制台中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?:

referencedParameters: 'Environment',

You can test out your groovy script in the script console at http://your-jenkins-server/script

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文