Issue
I deploy Jenkins on EKS, my pipeline is:
pipeline {
stage("build") {
//start a agent "agent_label"
}
//Now, end that agent, for the reason of waiting for user input.
stage("deploy") {
//start the agent "agent_label"
}
}
At the "build" stage, I get the git commit version, I want to use it in the "deploy" stage. Because the agent terminates, the environment variable in the "build" stage will be unavaliable. So how to solve it?
I have searched for it. It says I should use "Persistent Parameter". But there isn't a "Persistent Parameter" configuration on the Jenkins project type of "AWS Code commit" that I use. I only see that configuration on on the Jenkins project type of "Pipeline".
Another way may be changing the Jenkins BUILD_NUMBER to git commit version. But I do not know how to do that.
Thanks in advance!
Solution
Actually, the parameter can persistent even if the agent is shut down and restart. For example, if I set a varable in "build" stage, I can still get it at the "deploy" stage.
Also, for changing the Jenkins BUILD_NUMBER environment variable, you can use Build name setter plugin for Jenkins.
Answered By - Shuitian Wei