Manipulating environmental variables
This recipe shows you how to pass from Jenkins to your build job, and how different variables are overwritten. It also describes one way of failing the build if crucial information has not been correctly passed.
In a typical development/acceptance/production environment, you will want to keep the same pom.xml
files, but pass different configurations. One example is the extension names of property files such as .dev
, .acc
, and .prd
. You would want to fail the build if critical configuration values are missing due to human error.
Jenkins has a number of plugins for passing to builds, including the EnvFile
plugin (https://wiki.jenkins-ci.org/display/JENKINS/Envfile+Plugin) and the EnvInject
plugin (https://wiki.jenkins-ci.org/display/JENKINS/EnvInject+Plugin). The EnvInject
plugin was chosen for this recipe as it is reported to work with nodes and offers a wide range of property injection options.
Getting ready
Install the EnvInject
plugin (https://wiki.jenkins...