【问题标题】:Customizing "Build Executor Status" of Jenkins自定义 Jenkins 的“构建执行器状态”
【发布时间】:2021-02-01 22:46:52
【问题描述】:

我们有一个大型 RAILS 项目,我们正在遵循 Github 流程来推动我们的开发过程。我查看了所有可用的插件,但找不到任何自定义 Jenkins 主页的“Build executor status”部分的内容。

我想输入 git 分支的名称而不是作业名称和执行者编号,因为前者在我们的案例中更有意义。有人做过吗?

【问题讨论】:

  • 这绝对是可能的。这些天我在一些幻灯片上看到了它,但不记得了。

标签: jenkins jenkins-plugins


【解决方案1】:

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

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

或者,您可以使用Description Setter Plugin 根据构建输出更改构建描述(也显示在构建执行器状态中)。同样,您可以使用相同的技巧并使用 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'.

【讨论】:

    猜你喜欢
    • 2017-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-14
    • 1970-01-01
    • 2019-08-10
    • 1970-01-01
    • 2015-07-24
    相关资源
    最近更新 更多