Jenkins 常用插件 -- Parameterized Trigger plugin
? jenkins ?    2019-01-11 16:19:24    4908    0    0
gua_l   ? jenkins ?

参数化触发器

Parameterized Trigger plugin

https://wiki.jenkins.io/display/JENKINS/Parameterized+Trigger+Plugin


 

简单触发器

在项目中增加构建后操作步骤,build other projects(构建其他工程)

直接填写其他工程名,在满足触发时直接构建发列表中的工程(多个工程以英语中的逗号隔开)

 


 

参数化触发器

先安装Parameterized Trigger plugin 插件

在项目中增加构建后操作步骤,trigger Parameterized build on other projects

如下图,可以在Add Paramenters 中 选择传送的参数类型和方式。

比较常用的有以下三种

Current build parameters、parameters from properties file、Predifined parameters

 

Current build parameters :

在本项目的“参数化构建”中设置的参数,传送到下个项目传送的参数值为构建时填入的值,不会因为过程shell 的处理而变更,过程脚本对构建参数的重新赋值在脚本结束时失效。

 

parameters from properties file :

1. 如果需要传送的时在过程脚本中创建的参数及最终的值,可以使用从配置文件中读参数。将需要传送到下游在变量及值,按指定格式写到配置文件。

2. 比如,在执行Shell 的方框中,将 key = value 写入文件,然后在触发器中填写文件名。这种方面比较灵活,适用于,需要构建结束后才能得到最新value 的参数传送。

echo "Release_dir=$Release_dir" >$WORKSPACE/Release_info.txt
echo "Image_ver=$Image_ver" >>$WORKSPACE/Release_info.txt
cat $WORKSPACE/Release_info.txt​

 

Predifined parameters:

与配置文件类似,直接预填入 key = value 。但是value 是预定义的,值是不变的,适用于value 固定的参数传送。

 

注意,

1. 下游必须在“参数化构建” 中定义了参数名,如果下游项目没有使用参数化构建,将不会传送任何参数。

2. 上游使用Current build parameters (当前构建参数)进行传送时,下游接收到的参数值为上游构建时的初始赋值,(即使上游项目在构建过程中改变了参数的值,变化也不会传送)。

 


 

 

Pre: Jenkins 插件开发

Next: jenkins 构建脚本标记为failure

4908
Sign in to leave a comment.
No Leanote account? Sign up now.
0 comments
Table of content