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

时间:2019-07-22 09:34:25

标签: bash jenkins jenkins-plugins

我有2个詹金斯盒子,第一个作业用于轮询以触发第二个作业。 参数化的插件可以完美地工作,但是不能按照我想要的方式工作。所以这里的问题 我想在第一个作业获得“如果条件”成功时触发第二个作业(不仅仅是构建成功)。我希望“如果条件”为真,然后仅触发第二项工作

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

如果$ status与“ Ready”匹配,则只有它才能触发第二个工作

1 个答案:

答案 0 :(得分:0)

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

所以您的触发器看起来像:

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

远程触发的作业也可以参数化:)。