Set the build name and description from a Jenkins Declarative Pipeline

一个人想着一个人 提交于 2019-11-30 06:14:19

I think this will do what you want. I was able to do it inside a script block:

pipeline {
    stages {
        stage("Build"){
            steps {
                script {
                    currentBuild.displayName = "The name."
                    currentBuild.description = "The best description."
                }
                ... do whatever.
            }
        }
    }
}

The script is kind of an escape hatch to get out of a declarative pipeline. There is probably a declarative way to do it but i couldn't find it. And one more note. I think you want currentBuild.displayName instead of currentBuild.name In the documentation for Jenkins globals I didn't see a name property under currentBuild.

If you want to set build name to a job from a parameter, you can use

currentBuild.displayName = "${nameOfYourParameter}". Make sure you use double quotes instead of single quotes.

Job Configuration

Build job with parameter

Build History

REFERENCE: How to set build name in Pipeline job?

Cloudbees post regarding the same.Cloudbees

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!