詹金斯下拉等职务构建名单 [英] Jenkins drop down list of build names of other job

查看:328
本文介绍了詹金斯下拉等职务构建名单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想列出在下拉菜单中得到了由另一个作业构建的所有全成建的名字。我所见过的链接获得在下拉与参数化和复制文物插件菜单生成ID的所有名单。但我需要通过构建二传手在其他岗位设置实际构建的名字列出。目前,我能够得到清单,#55,54,53,52等..,但我需要分配给这些构建一个得到了由二传手构建设置构建的名称上市。

I would like to list out all successfull build names in the drop down menu that got built by another job. I have seen the links to get all list of build ids in the drop down menu with parametrized and copy artifacts plugins. But I need to list with the actual build names set by Build Setter in the other job. Currently i am able to get list with #55,54,53,52.. etc., But I need to list with build names assigned to these builds that got set by build setter.

code段:

import jenkins.model.Jenkins
import hudson.model.AbstractProject
import hudson.model.Result
import hudson.util.RunList
AbstractProject<?, ?> otherJob = Jenkins.getInstance().getItemByFullName("iOS_plugin-5.0-build", AbstractProject.class)
RunList<?> builds = otherJob.getBuilds().overThresholdOnly(Result.SUCCESS)

def list = builds.limit(5).collect { it.number }

问候,
SRINIVAS

Regards, Srinivas

推荐答案

我可以构建对象的显示名属性来检索构建的名称(与构建名称二传手插件设置)。

I can retrieve the build name (set with the Build Name Setter plugin) with the "displayName" property of the build object.

这是我的工作的例子,作为一个动态的参数选择常规插件:

Here is my working example, as a "Dynamic Choice Parameter" groovy plugin:

def jobname="build-my-project"
def list=[]
hudson.model.AbstractProject<?, ?> otherJob = jenkins.model.Jenkins.getInstance().getItemByFullName(jobname, hudson.model.AbstractProject.class)
hudson.util.RunList<?> builds = otherJob.getBuilds().overThresholdOnly(hudson.model.Result.SUCCESS)
builds.limit(20).each{run -> list.add(run.displayName) }
list

我希望这有助于!

I hope this helps!

这篇关于詹金斯下拉等职务构建名单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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