如何通过 Jenkins 中的 Global Builds Stats Plugin 脚本提取信息
How to extract information through script from Global Builds Stats Plugin in Jenkins
我需要每周发送一封邮件,其中包含有关 jenkins 工作 运行 的详细信息。我已经成功安装了插件,也可以看到图表了。
有人可以在脚本部分指导我,如何提取数据并发送邮件。另外,如果数据可以以图形形式发送,那将是最好的。
使用下面的命令我可以直接在浏览器中看到图表。
<jenkins/hudson_url>/plugin/global-build-stats/showChart?buildStatId=<Chart id>
但是,当我尝试使用下面的 curl 命令下载图像时,我没有得到它。
curl -O <jenkins/hudson_url>/plugin/global-build-stats/showChart?buildStatId=<Chart id>
获取以下两个文件,不是图片或相关数据。
-rw-r--r--. 1 root root 62 Nov 14 07:04 osw.hb
-rw-------. 1 root root 969 Nov 14 07:04 showChart?buildStatId=<chart id>
"showchartfile"的内容如下。
Authentication required
<!--
You are authenticated as: anonymous
Groups that you are in:
Permission you need to have (but didn't): hudson.model.Hudson.Read
... which is implied by: hudson.security.Permission.GenericRead
... which is implied by: hudson.model.Hudson.Administer
-->
</body></html>
这看起来像是身份验证问题。理想情况下,它不应该出现,因为我正在使用图表 ID。以下是 API.
的文档 link
https://wiki.jenkins.io/pages/viewpage.action?pageId=46336030
我找到问题了。图表 ID 仅适用于现有用户。这意味着 curl 命令需要提供用户名和密码。下面一位用过。现在可以使用了。
curl -u Username:Passwd -O <jenkins/hudson_url>/plugin/global-build-stats/showChart?buildStatId=<Chart id>
我需要每周发送一封邮件,其中包含有关 jenkins 工作 运行 的详细信息。我已经成功安装了插件,也可以看到图表了。
有人可以在脚本部分指导我,如何提取数据并发送邮件。另外,如果数据可以以图形形式发送,那将是最好的。
使用下面的命令我可以直接在浏览器中看到图表。
<jenkins/hudson_url>/plugin/global-build-stats/showChart?buildStatId=<Chart id>
但是,当我尝试使用下面的 curl 命令下载图像时,我没有得到它。
curl -O <jenkins/hudson_url>/plugin/global-build-stats/showChart?buildStatId=<Chart id>
获取以下两个文件,不是图片或相关数据。
-rw-r--r--. 1 root root 62 Nov 14 07:04 osw.hb
-rw-------. 1 root root 969 Nov 14 07:04 showChart?buildStatId=<chart id>
"showchartfile"的内容如下。
Authentication required
<!--
You are authenticated as: anonymous
Groups that you are in:
Permission you need to have (but didn't): hudson.model.Hudson.Read
... which is implied by: hudson.security.Permission.GenericRead
... which is implied by: hudson.model.Hudson.Administer
-->
</body></html>
这看起来像是身份验证问题。理想情况下,它不应该出现,因为我正在使用图表 ID。以下是 API.
的文档 linkhttps://wiki.jenkins.io/pages/viewpage.action?pageId=46336030
我找到问题了。图表 ID 仅适用于现有用户。这意味着 curl 命令需要提供用户名和密码。下面一位用过。现在可以使用了。
curl -u Username:Passwd -O <jenkins/hudson_url>/plugin/global-build-stats/showChart?buildStatId=<Chart id>