Set the build name and description from a Jenkins Declarative Pipeline
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?
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.