Jenkins multibranch:更改Groovy的职位描述 [英] Jenkins multibranch: change Job description from Groovy
问题描述
我可以通过使用 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 myJenkinfile
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屋!