[英]How to determine which job is executed most often in Jenkins?
您知道如何确定给定期间的每个作业执行次数吗?
The following XPath expression will return the number of builds with timestamps between 1329817773921
and 1329834427888
for job MyJobName : 以下XPath表达式将返回作业MyJobName的时间戳为
1329817773921
和1329834427888
之间的1329817773921
版本数:
http://[jenkins_server]/api/xml?depth=2&xpath=string(count(/hudson/job[name='MyJobName']/build[timestamp>=1329817773921 and timestamp<=1329834427888]))
The timestamps themselves are the standard number of milliseconds since the epoch . 时间戳本身是自epoch以来的标准毫秒数。
The following XPath can be used to determine the number of different jobs on the server: 以下XPath可用于确定服务器上不同作业的数量:
http://[jenkins_server]/api/xml?depth=2&xpath=string(count(/hudson/job))
The following XPath can be used to determine the name of the third job on the server: 以下XPath可用于确定服务器上第三个作业的名称:
http://[jenkins_server]/api/xml?depth=2&xpath=/hudson/job[3]/name/text()
You can write a short shell script that combines those queries executed via wget
to get the desired result. 您可以编写一个简短的shell脚本,该脚本结合了通过
wget
执行的那些查询,以获得所需的结果。
Basing on @malenkly_scot answer I managed to retrieve statistic information about jobs count during last month. 基于@malenkly_scot的答案,我设法检索了有关上个月的工作计数的统计信息。
Below the steps: 步骤如下:
http://buildcontrol//api/xml?depth=2&xpath=%28/hudson/job[build[timestamp%3E=1328054460000%20and%20timestamp%3C=1330560060000]]%29&wrapper=jenkins
http:// buildcontrol // api / xml?depth = 2&xpath =%28 / hudson / job [build [timestamp%3E = 1328054460000%20and%20timestamp%3C = 1330560060000]]%29&wrapper = jenkins
You can use this page to resolve timestamp values: Epoch converter 您可以使用此页面来解析时间戳值: 历元转换器
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<?xml版本=“ 1.0”编码=“ utf-8”?> <xsl:stylesheet版本=“ 1.0” xmlns:xsl =“ http://www.w3.org/1999/XSL/Transform” xmlns:msxsl =“ urn:schemas-microsoft-com:xslt” exclude-result-prefixes =“ msxsl”>
<xsl:template match="/"> name;count;
<xsl:template match =“ /”> name; count; <xsl:apply-templates select="/jenkins/job"></xsl:apply-templates> </xsl:template>
<xsl:apply-templates select =“ / jenkins / job”> </ xsl:apply-templates> </ xsl:template>
<xsl:template name="job" match="/jenkins/job"> <xsl:apply-templates select="displayName"/>;<xsl:value-of select="count(./build)"/> <xsl:text>;
<xsl:template name =“ job” match =“ / jenkins / job”> <xsl:apply-templates select =“ displayName” />; <xsl:value-of select =“ count(./ build)” /> <xsl:text>; </xsl:text> </xsl:template>
</ xsl:text> </ xsl:template>
</xsl:stylesheet>
</ xsl:stylesheet>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.