詹金斯(Jenkins)将徽章设置为预构建步骤 [英] Jenkins set a badge as a pre-build step

查看:123
本文介绍了詹金斯(Jenkins)将徽章设置为预构建步骤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定我在这里使用的术语是否正确,因此我将尽力解释最好的情况.我使用Jenkins来运行我们的Java自动化.有许多长时间运行(2到10个小时)的作业会针对被测试产品的不同版本不断执行.我需要一种方法来快速查看作业的构建历史记录"框,并查看哪个作业正在测试哪个产品版本.

I'm not sure I have terminology quite correct here, so I will try to explain as best as possible. I use Jenkins to run our Java automation. There are lots of long-running (2-10 hours) jobs executing constantly against different versions of the product under test. I need a way to look quickly at the Build History box of a job, and see which job is testing which product version.

我已成功使用Groovy Postbuild插件在构建历史记录"框中的构建右侧添加了一个徽标(我认为就是这样).实际的groovy命令是:

I've used the Groovy Postbuild plugin successfully to add a badge (I think that is what it is) to the right of the build in the Build History Box. The actual groovy command is:

manager.addShortText(version, "grey", "white", "0px", "white")

与此有关的问题是,直到构建完成,它才能运行.在构建开始之前,我需要做类似的事情. (我将可以访问预构建版本,因为它是作为参数传递的)

The problem with this, is that it does not run until the build is complete. I need to do something like this before the build starts. (I will have access to the version pre-build, as it is passed in as a parameter)

推荐答案

您可以使用Groovy插件(而不是groovy后构建)并执行脚本作为构建的第一个动作(您需要依次使用系统脚本)访问詹金斯的课程.

You could use the Groovy Plugin (not groovy post-build) and execute a script as first action of your build (you need to use a system script in order to access Jenkins' classes.

但是请注意,在groovy post build插件中的mananger是快捷方式,因此您将需要以下内容:

Note however, that the mananger in groovy post build plugin is a shortcut, so you would need something like:

build.getActions().add(GroovyPostbuildAction.createShortText(text));

更新:

由于上述构造无法正常工作,请尝试:

Update:

Since the above construct does not quite work, try:

 def action = new org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildAction(null, text);
 action.color = "grey";
 build.getActions().add(action);

或者,您可以只设置说明:

Alternativly, you could just set the description:

build.description = text

这篇关于詹金斯(Jenkins)将徽章设置为预构建步骤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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