簡體   English   中英

Jenkins腳本化或聲明性管道-如何設置職位描述文本

[英]Jenkins scripted or declarative pipeline - how to set job description text

有誰知道如何為詹金斯腳本或聲明性管道中定義的作業設置描述文本? 原因:我想添加一些有關這項工作的有意義的文字(小的文檔)。

此解決方案通過jenkins中的常規腳本更改了作業項目的描述。 我只在自由式工作中使用過它,但我認為它也應該在腳本化管道中工作

import jenkins.model.*
final jenkins   = Jenkins.getInstanceOrNull()
final myJob     = jenkins.getItem("MyJobName")

description = "<h1 style=\"color:green\">The newest build has number ${env.BUILD_NUMBER}</h1>"
myJob.setDescription(description)
myJob.save()

此解決方案更改了對構建描述 :使用'currentbuild'全局變量。

即聲明性管道:

script { currentbuild.description = 'New Description' }

在腳本化管道中的工作方式相同:)

參考: https : //opensource.triology.de/jenkins/pipeline-syntax/globals

用於聲明性管道

script {
       currentBuild.description = "description env var if required :${env.ver}"
}

對於腳本

currentBuild.description = "description env var if required :${env.ver}"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM