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 .
相关问题
- how to split a list into a given number of sub-lis
- Generate string from integer with arbitrary base i
- Converting a string array to a byte array
- Jenkins - cmd is not recognized
- How to convert a string to a byte array which is c
相关文章
- dotnet restore还原nuget包时无法加载 https://api.nuget.org/
- jenkins在window集群环境中如何部署自动化发布?
- jenkins + Publish over FTP 自动部署前端React项目
- jenkins自定打包部署React前端项目遇到的问题。
- JSP String formatting Truncate
- Handling ffmpeg library interface change when upgr
- Selecting only the first few characters in a strin
- Best way to manage docker containers with supervis
Just provide a default value to the string parameter. As long as you do not change it, it's optional. You will simply have to check whether the parameter is set to the default and depending on the same, you can decide the course of action.
Check the option 'This build is parameterized'. Now select 'String Parameter'. To access the parameter from bash script, you just have to check the value of the variable that you assign to 'Name' textbox as shown in the fig.
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.
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.
If your parameter is called "Param", you can access it's value through:
${Param}
on Linux.%Param%
on Windows.Edit to answer comments:
To pass params from a "parent" build to the downstream builds, depends on how you trigger the downstream builds. If you are using Call/Trigger Parameterized Build plugin (which you should be), then there is a simple option to pass parent parameters to downsteam builds. They will be available in child builds through the same param name, like
${Param}
in the above example.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