如何在构建名称中使用构建原因? [英] How to use the build cause in build name?

查看:146
本文介绍了如何在构建名称中使用构建原因?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用API​​远程触发作业时,jenkins上的作业会说:由远程主机IP启动".但是我的工作可能因不同的原因和来自不同的来源而被触发,所以如果我在詹金斯可以看一下工作并直接看到触发原因,那将是很棒的事情.

When I trigger a job remotely using the API the job on jenkins say: "Started by remote host IP". But my jobs can trigger for different reasons and from different sources so it would be great if I in Jenkins could look at a job and directly see the trigger reason.

我知道我可以传递一个字符串参数,然后在每个作业视图中传递参数-但这不是很明显.我希望最好已经在所有作业列表中看到它.类似于:Reason: X Source: N.

I know I could pass a string parameter and then in each job view the parameters - but that's not very visible. I would like to preferably see it already in the list of all jobs. Something like: Reason: X Source: N.

有什么办法吗?

我注意到我们的发布作业采用的版本参数显示为我想要的-但是我不想滥用它,因为这些运行不是发行版.

I have noticed that our release jobs take a version parameter that shows like I want - but I don't want to abuse that since these runs are not releases.

推荐答案

内部名称

我认为您想将构建名称设置为另一个类似的名称:

Build Name

I think you want to set the build name to a different one like here:

因此,您可以使用构建名称设置器插件并使用构建步骤更新构建名称.

So you can use the Build Name Setter Plugin and use the build step Update build name.

对于您的情况,您可以使用:

For your case you can use:

#${BUILD_NUMBER} ${BUILD_CAUSE}

原因徽章

查看构建触发器徽章插件,并用图标表示生成的原因.

Cause Badge

Have a look on Build Trigger Badge Plugin, it represents with an icon the reason of the build.

提取工作原因的一种可能性是使用常规方法,将currentBuild注入运行时,并包含有关原因的信息,等等.

One possibility to extract the job cause is to use groovy, currentBuild is injected into the runtime and includes information about the causes and so on.

这将打印出第一个(!)原因:

This prints the first (!) cause:

println ("Cause: " + currentBuild.causes[0])

这篇关于如何在构建名称中使用构建原因?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆