Jenkins pipeline plugin: set the build description

Just figured it out. The pipeline job exposes a currentBuild global variable with writable properties. Setting the description can be done with:

currentBuild.description = "my new description"

anywhere in the pipeline script. More information in this DZone tutorial.


The answer from @jjst describes how to set the build description in "scripted pipelines". In declarative pipelines you can do the same, but need to place it inside a script { } block. Here a complete working example taken from 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"
                }
            }
        }
    }
}