Jenkins pipeline plugin: set the build description

后端 未结 4 1527
自闭症患者
自闭症患者 2021-02-02 05:51

I\'m trying to replace our current build pipeline, currently hacked together using old-school Jenkins jobs, with a new job that uses the Jenkins pipeline plugin, and loads a

相关标签:
4条回答
  • 2021-02-02 06:29

    This may not have been the case when jjst wrote his answer but now with the latest jenkins and plugins you can set this outside the main pipeline at the top. This means you dont have to embed script setting and have special steps etc eg

    currentBuild.description = "my new description"
    pipeline {...
    

    or

    currentBuild.description = """
    blah
    blah
    blah
    """
    pipeline {
    
    0 讨论(0)
  • 2021-02-02 06:33

    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 an example taken from comments on the Cloudbees article:

    pipeline {
        agent any
        stages {
            stage("1st stage") {
                steps {
                    script {
                        currentBuild.displayName = "My custom build name"
                        currentBuild.description = "My custom build description"
                    }
                }
            }
        }
    }
    
    0 讨论(0)
  • 2021-02-02 06:36

    I'm not sure how old it is, but I recently discovered the buildDescription plugin that gives you a declarative method to set the build description. Once installed, it's as easy as:

    steps {
      buildDescription 'my build'
    }
    

    The console will show a step output: New run description is 'my build'

    0 讨论(0)
  • 2021-02-02 06:46

    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.

    0 讨论(0)
提交回复
热议问题