Set the build name and description from a Jenkins Declarative Pipeline

前端 未结 2 1994
谎友^
谎友^ 2020-12-29 02:08

I would like to set the build name and description from a Jenkins Declarative Pipeline, but can\'t find the proper way of doing it. I tried using an environment bracket afte

相关标签:
2条回答
  • 2020-12-29 02:57

    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?

    0 讨论(0)
  • 2020-12-29 03:01

    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.

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