如何在詹金斯管道中设置默认选择? [英] How do I set a default choice in jenkins pipeline?

查看:21
本文介绍了如何在詹金斯管道中设置默认选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

非常令人沮丧,我找不到这样的例子.如何设置默认选项?

quite frustrating I can't find an example of this. How do I set the default choice?

parameters {
    choice(
        defaultValue: 'bbb',
        name: 'param1',
        choices: 'aaa
bbb
ccc',
        description: 'lkdsjflksjlsjdf'
    )
}

defaultValue 在这里无效.如果管道以非手动方式运行(通过提交),我希望选择是可选的并设置默认值.

defaultValue is not valid here. I want the choice to be optional and a default value to be set if the pipeline is run non-manually (via a commit).

推荐答案

您不能在选项中指定默认值.根据 choice 输入的文档,第一个选项将是默认选项.

You can't specify a default value in the option. According to the documentation for the choice input, the first option will be the default.

潜在的选择,每行一个.第一行的值将是默认值.

The potential choices, one per line. The value on the first line will be the default.

您可以在 文档源,以及它是如何在 源代码.

You can see this in the documentation source, and also how it is invoked in the source code.

return new StringParameterValue(
  getName(), 
  defaultValue == null ? choices.get(0) : defaultValue, getDescription()
);

这篇关于如何在詹金斯管道中设置默认选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆