【问题标题】:Display build result from one Jenkins master in another master's radiator?在另一个主的散热器中显示一个 Jenkins 主的构建结果?
【发布时间】:2016-09-04 19:09:25
【问题描述】:

我们有一个构建项目的 Jenkins 主构建服务器。我们有另一个 Jenkins 主构建服务器在大屏幕上显示“散热器”视图。

我们可以在第二个的散热器视图上显示第一个主的构建结果吗?

【问题讨论】:

  • 您必须对第二个主服务器的构建和作业目录进行符号链接,或者持续复制文件以保持主服务器同步。
  • 为什么不使用外部构建散热器?

标签: jenkins


【解决方案1】:

我们也有同样的需求。似乎没有直接执行此操作的 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-29
    • 2018-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多