我正在尝试用一个使用Jenkins管道插件并从项目存储库加载Jenkinsfile
的新作业来替换我们当前的构建管道,目前使用的是老式Jenkins作业。
遗留作业所做的一件事是设置构建描述,以包括Mercurial哈希、用户名和使用Description setter plugin的当前版本,以便很容易找到构建。
有没有办法用Jenkins管道插件复制/模拟这种行为?
发布于 2016-04-08 21:57:41
我就想明白了。管道作业公开了一个具有可写属性的currentBuild
全局变量。可以使用以下命令设置描述:
currentBuild.description = "my new description"
管道脚本中的任何位置。有关详细信息,请参阅此DZone tutorial。
发布于 2018-11-23 02:03:52
@jjst的回答描述了如何在“脚本化管道”中设置构建描述。在声明性管道中,您也可以这样做,但需要将其放在script { }
块中。下面是取自comments on a Cloudbees article的一个完整的工作示例
pipeline {
agent any
stages {
stage("1st stage") {
steps {
script {
currentBuild.displayName = "My custom build name"
currentBuild.description = "My custom build description"
}
}
}
}
}
发布于 2018-12-06 18:54:45
当jjst写下他的答案时,情况可能并非如此,但现在有了最新的jenkins和插件,您可以将其设置在主管道之外的顶部。这意味着你不必嵌入脚本设置和有特殊的步骤等,例如
currentBuild.description = "my new description"
pipeline {...
或
currentBuild.description = """
blah
blah
blah
"""
pipeline {
https://stackoverflow.com/questions/36501203
复制相似问题