简体   繁体   English

jenkins参数化触发器插件来触发另一个构建

[英]jenkins Parameterized Trigger Plugin to trigger another build

I have 2 jenkins box, 1st job is used for polling to trigger 2nd job. 我有2个詹金斯盒子,第一项工作用于轮询以触发第二项工作。 the parameterized plugin works just perfectly, but its not working the way I wanted. 参数化的插件可以完美地工作,但是不能按照我想要的方式工作。 So here the problem I want to trigger 2nd job when 1st job gets "if condition" is success ( not just the build is successful ). 因此,这里的问题是我想在第一个作业获得“ if condition”成功时触发第二个作业(不仅仅是构建成功)。 I want the "if condition" to be true and then only trigger the 2nd job 我希望“如果条件”为真,然后仅触发第二个作业

status=`cat ${DIR}/CRQ-*/crqDetails.properties | grep -F ENV_VALUE_10 | cut -d '=' -f2 | tail -1`
# Checking the status of the CRQ for the execution
if [[ ${status} == "Ready" ]]; then
  echo "Executing ${CRQ}"
else 
  echo "No CRQ's for execution"
fi

If the $status gets matched with "Ready" then only it should trigger 2nd job 如果$ status与“ Ready”匹配,则只有它应该触发第二个作业

You cam trigger Jenkins job with simple cURL. 您可以使用简单的cURL触发Jenkins作业。 Look at this thread on server fault https://serverfault.com/questions/888176/how-to-trigger-jenkins-job-via-curl-command-remotely . 在服务器故障https://serverfault.com/questions/888176/how-to-trigger-jenkins-job-via-curl-command-remotely上查看此线程。

So your trigger would look like: 因此,触发器将如下所示:

status=`cat ${DIR}/CRQ-*/crqDetails.properties | grep -F ENV_VALUE_10 | cut -d '=' -f2 | tail -1`
# Checking the status of the CRQ for the execution
if [[ ${status} == "Ready" ]]; then
  echo "Executing ${CRQ}"
  curl -u auto:<jenkins_user_token> http://<jenkins_server>/job/JOR_JOB/build?token=wefiytgwiefiweihfqweiodf
else 
  echo "No CRQ's for execution"
fi

The remotely triggered jobs can also be parametrized :). 远程触发的作业也可以参数化:)。

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

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