Step 1: Add environment variables to Jenkins.
Open the global or project configuration page, depending on your needs, and scan for the Variable Environment section. Check the box and use the Add button to add key / value pairs.
They will be passed by Jenkins to your Ant build script.
Step 2: Download them to Ant.
At the top of your Ant build.xml
script, load all environment variables with the env
prefix so that they do not interfere with other properties.
<property environment="env"/>
Now all imported variables will be accessible using the env
prefix, for example. ${env.HOME}
.
Step 3: Pass them to PHPUnit.
Assuming you use the <exec>
task to run PHPUnit, you can pass each variable it needs using a child element of <env>
.
<exec taskname="test" executable="phpunit"> <env key="APPLICATION_ENV" value="${env.APPLICATION_ENV}"/> ... </exec>
Note. . You can only try the first step to see if Ant will pass environment variables along with executable child processes, but I think the other two steps are good for creating it clearly what other developers need.
source share