Jenkins multibranch:更改Groovy的职位描述 [英] Jenkins multibranch: change Job description from Groovy

查看:142
本文介绍了Jenkins multibranch:更改Groovy的职位描述的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Jenkins中的多分支项目工作正常,但我想将作业描述(默认为完整项目名称:xxxx /)修改为更有意义的内容。



我可以通过使用 currentBuild 变量轻松更改构建描述,这些变量在我的 Jenkinfile code>被执行,但我不知道如何修改父作业说明。



我的使用案例是我的存储库的每个分支都有一个关联容器在完成时使用最新版本进行更新。因此,我的multibranch项目中的每个作业都有其容器和Web URI,我希望将其放入作业说明中。



这可能吗?

解决方案

如何使用Jenkins Api更新当前作业的描述?例如:

更新顶级多分项目描述:

  def jobName =$ {env.JOB_NAME}
Jenkins.instance.getItem(jobName.split('/')[0])。description =hi



更新multibranch项目中特定分支项目的描述:

  def jobName =$ {env.JOB_NAME}
Jenkins.instance.getItem(jobName.split('/')[0])。getItem($ {env.BRANCH_NAME})。 description =hi

注意:您需要通过Manage Jenkins 正在处理脚本批准


My multibranch project in Jenkins works fine, but I would like to modify the job description, which is by default "Full project name: xxxx/", to something more meaningful.

I can easily change the build description by using the currentBuild variable that is available when my Jenkinfile is executed, but I can't figure how to modify the parent job description.

My use case is that each branch of my repository has an associated container that is updated with the latest build when it is finished. So each of the jobs in my multibranch project has its container and web URI, that I would like to put into the job description.

Is this possible?

解决方案

How about using the Jenkins Api to update the current job's description? Something like:

To update the top multibranch project description:

def jobName = "${env.JOB_NAME}"
Jenkins.instance.getItem(jobName.split('/')[0]).description = "hi"

To update a specific branch project's description in the multibranch project:

def jobName = "${env.JOB_NAME}"
Jenkins.instance.getItem(jobName.split('/')[0]).getItem("${env.BRANCH_NAME}").description = "hi"

Note: You will need to approve several functions via "Manage Jenkins" -> "In process Script Approval"

这篇关于Jenkins multibranch:更改Groovy的职位描述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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