简体   繁体   English

Jenkins管道参数代码,用于多个活动选择

[英]Jenkins pipeline parameter code for multiple active choices

For Active choice parameter Jenkins pipeline code 对于主动选择参数Jenkins管道代码

Project: 项目:

         []project1
         []project2
         []project3
         []project4

[] is a checkbox, we can select single or multiple projects. []是一个复选框,我们可以选择单个或多个项目。 I need the pipeline parameter code to bring this in Jenkins build parameter tab. 我需要管道参数代码将其引入Jenkins构建参数选项卡。

If you have already installed Active choice parameter plugin, please refer this article on medium which can tell you step by step how to build using checkboxes under active choice parameter. 如果您已经安装了“主动选择参数”插件,请参阅本文,该媒体可以逐步告诉您如何使用“主动选择参数”下的复选框进行构建。

Jenkins Active Choice parameter usecase Jenkins Active Choice参数用例

You can use bash shell to define the logic of the user input, by just using the variable as the parameter name. 您可以使用bash shell通过仅将变量用作参数名称来定义用户输入的逻辑。 Put them inside a loop if you running a build script which has to applied to all the options selected. 如果您运行的构建脚本必须应用到所有选择的选项,请将它们放入循环中。

IFS=","
#user choices value will be a comma separated value 
domain=$YOUR_ACTIVE_CHOICE_PARAMETER_NAME

# get length of an array
names=($domain);

arraylength=${#names[@]}


# use for loop to read all values and indexes
for (( i=0; i<${arraylength}; i++ )); do

    echo "==========="
    <Your logic for build process>
    echo "==========="

done

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM