本文介绍了如何使用可选复选框将字符串参数添加到Jenkins的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的jenkins版本中添加一个String参数,但是我找不到使它可选的选项,在Jenkins WIKI上我找到了一个screeshot并且有一个使其可选的选项:。

I'm trying to add a String parameter to my jenkins build, but i can't find an option to make it optional, on the Jenkins WIKI i found a screeshot and there was an option to make it optional: https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Build .

推荐答案

所有参数均为可选。除非它是,否则Jenkins不会

All parameters are "optional". Unless it's a Validating String Parameter, Jenkins doesn't care what value you've entered or if you've entered anything at all.

唯一关心参数的是您的工作实现,即脚本(bash)和配置为使用该参数的其他操作。

The only thing that cares about the parameters is your job implementation, i.e. your scripts (bash) and other action that are configured to use the parameter.

如果您的参数名为 Param ,则可以访问其值通过:

If your parameter is called "Param", you can access it's value through:


  • $ {Param} 在Linux上。

  • %Param%在Windows上。

  • ${Param} on Linux.
  • %Param% on Windows.

编辑以回答评论:

要将参数从父构建传递到下游构建,取决于触发下游构建的方式。如果您使用的是 插件( (应该是),然后有一个简单的选项将父参数传递给downsteam版本。它们可以通过相同的参数名称在子版本中使用,例如上例中的 $ {Param}

如果您以其他方式触发它,则有多种解决方法,主要是通过将它们存储在属性文件中,然后通过插件

If you are triggering it some other way, there are a number of workarounds, mainly through storing them in a property file and then loading that property file in child build through EnvInject plugin

这篇关于如何使用可选复选框将字符串参数添加到Jenkins的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 22:36