我们有一个构建项目的Jenkins主构建服务器。我们有另一个Jenkins主构建服务器在大屏幕上显示“散热器”视图。
我们可以在第二个散热器视图的第一个主设备上显示构建结果吗?
答案 0 :(得分:0)
我们有同样的需求。似乎没有Jenkins支持或插件直接执行此操作。所以我最终创建了一个小的bash脚本,轮询其他Jenkins主API,以镜像构建状态。我们将其设置为每10分钟触发一次。你需要安装curl和jq来运行它:
运行方式如下:./jenkins_monitor.sh https://jenkins.example.com/job/my-job-name/
#!/bin/bash
# Remote Jenkins job monitoring script that polls the API to mirror the job status
# Useful for pulling status of jobs on other Jenkins servers into a Walldisplay
JOB_URL="$1"
if [ "$JOB_URL" == "" ]; then
echo "Usage: $0 http://{jenkins-server}/job/{job-name}"
exit
fi
JOB_DATA=`curl --fail --insecure --silent --show-error 2>&1 "${JOB_URL}/lastBuild/api/json"`
JOB_RESULT=`echo $JOB_DATA|jq .result 2>/dev/null`
if [ "$JOB_RESULT" == "" ]; then
echo "Error when retrying Jenkins job info:"
echo $JOB_DATA
exit 1
fi
echo "Job status is: ${JOB_RESULT}"
if [ "$JOB_RESULT" == '"FAILURE"' ]; then
echo "Remote job failed"
exit 1
elif [ "$JOB_RESULT" == 'null' ]; then
echo "Remote job is building"
else
echo "Job seems to be fine"
fi