2012-07-08 24 views
4

我们有一个大的RAILS项目,我们正在关注Github流程来推动我们的开发过程。我浏览了所有可用的插件,但找不到任何定制jenkins首页的“Build executor status”部分。我想把git分支的名字,而不是工作名称和执行者号码,因为前者在我们的情况下更有意义。有人做过这个吗?定制Jenkins的“构建执行器状态”

+0

这是明确可能的。我最近在一些幻灯片上看到它,但不记得了。 – roehrijn 2013-10-08 13:46:47

回答

1

您可以使用Build Name Setter Plugin更改基于可用令牌的名称。 我不确定一个TOKEN是否存在于你的Git分支名称中,但如果所有其他的都失败了,你可以使用shell脚本构建步骤并将其写入属性文件,然后使用宏:$ {PROPFILE,.. },如:

#${BUILD_NUMBER}_${PROPFILE,file="parameters.properties",property="BUILD_TYPE"} 

或者,您可以使用Description Setter Plugin改变基础上,构建输出的生成描述(也出现在Build执行人状态)。再次,您可以使用相同的技巧并使用shell脚本在构建输出中打印出分支名称,并使用正则表达式将其从构建日志中解析出来。

一个小的限制:任何一个只会在作业完成后更新名称/描述,因此对于长时间运行的作业,它不会立即可见。但是对于短的和审计目的来说,这很有效。

[编辑] 一段时间后,我开始使用EnvInject plugin,它将我的构建参数尽早地添加到环境中,以便Build Name Setter Plugin能够使用它们。

这具有立即设置构建名称的优点。

此外,您可以通过$ {GIT_BRANCH}获得Git分支。这里是它的文档:

${GIT_BRANCH} 
    Expands to the name of the branch that was built. 

Parameters: 

all 
    If specified, all the branches that point to the given commit is listed. 
    By default, the token expands to just one of them. 

fullName 
    If specified, this token expands to the full branch name, such as 'origin/master'. 
    Otherwise, it only expands to the short name, such as 'master'.