jenkins Parameterized Trigger Plugin 触发另一个构建

jenkins Parameterized Trigger Plugin to trigger another build

我有 2 个 jenkins box,第一个作业用于轮询以触发第二个作业。 参数化插件工作得很好,但它没有按照我想要的方式工作。所以这里的问题 我想在第一份工作 "if condition" 成功时触发第二份工作(不仅仅是构建成功)。我希望 "if condition" 为真,然后只触发第二个作业

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" 匹配,那么只有它应该触发第二个作业

您可以使用简单的 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

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