In Jenkins job configuration I have written a bat script in the command window of build section. In one of the script commands I set an environment variable as a system environment variable in the server machine as so:
setx Analysis_URL "http://analysis_url/analysis/%analysis_id%.html
My task now is to get this environment variable value back to Jenkins and include it in my post build notification email content. Is there a simple way to do it ?
In my research I have come across the plugin envInject but I think it is used for setting environment variables, is that right ?
UPDATE 1 :
It turned out that the variable could be accessed by a simple $Analysis_URL in the email content, however, that raised another issue as my environment variable changes its value after each job build, but as Jenkins only takes a copy of the system environment variables I keep getting the same variable value after each build in my email content, it only changes after restarting Jenkins. Is there a way to get the updated system environment variables to Jenkins ?
UPDATE 2 :
EnvInject plugin did the job I wanted. These are the steps that I performed:
- Build step "batch command window": added command :
echo ANALYSIS_URL=$ANALYSIS_URL > my.properties
- Build step "Inject environment variables": in field "Properies File Path"
$WORKSPACE/my.properties
- Post-Build Actions: "Editable Email Notification", Field "Default Content":
Current analysis url: $ANALYSIS_URL