gpt4 book ai didi

jenkins - 具有相关参数的参数化 Jenkins 作业

转载 作者:行者123 更新时间:2023-12-04 01:53:32 24 4
gpt4 key购买 nike

我正在尝试创建一个具有相关参数的 Jenkins 作业。

首先,我希望能够选择一个主要参数:enter image description here
其次,能够从作为主要参数的依赖参数的一组选项中进行选择。 enter image description here

如果我选择不同的主要参数:enter image description here

然后我希望有一组不同的选项作为第二个主要参数的依赖项。 enter image description here

拜托,你能帮我解决这个问题吗?

最佳答案

我建议使用 Active Choices plugin (也称为“uno-choice”)。 ( This questionreferencesboth ,尽管它们不是公认的答案。)

对于您的特定用例,您需要向作业添加两个参数:

  • 主动选择参数
  • 姓名 : MainOption
  • 脚本 : Groovy 脚本
    return ['A','B']
  • 主动选择 react 参数
  • 姓名 : DependentOption
  • 脚本 :Groovy 脚本
    def choices
    switch(MainOption){
    case 'A':
    choices = ['Blue','Green','Yellow']
    break
    case 'B':
    choices = ['Black','White','Grey']
    break
    default:
    choices = ['N/A']
    break
    }
    return choices
  • 回退脚本 : Groovy 脚本
    return ['Option error']
  • 引用参数 :
    MainOption

  • “引用参数”设置是关键——当该值改变时,插件将重新评估 Groovy 脚本,为您提供依赖参数效果。

    关于jenkins - 具有相关参数的参数化 Jenkins 作业,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51845050/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com