Interview Prep/CI/CD/Jenkins in Production

How do you pass build metadata (version, commit) reliably between Jenkins stages?

BeginnerProductionJenkins in Production
Answer

Compute once in an early stage and store in env.VAR (visible across stages and agents), or write a small build.properties file and stash it. Avoid Groovy global variables for values needed after an agent change, and avoid recomputing the version in each stage, which can produce different values.

script { env.APP_VERSION = "1.4.${env.BUILD_NUMBER}-${env.GIT_COMMIT.take(7)}" }
All CI/CD questions

More on Jenkins in Production