Jenkins Post Build Task: access jenkins environment variables like JOB_NAME

I want to get job information in the Post Build Task plugin and pass the details to the / powershell package for further processing.

I cannot access Jenkins environment variables like JOB_NAME, JOB_ID, etc.

Post Build Plugin Task

Text BUILD SUCCESSFUL OPTION

Script Block: run.bat $ JOB_NAME- $ JOB_ID

I need to pass $ JOB_NAME- $ JOB_ID to the script.

+8
jenkins-plugins
source share
2 answers

Typically, sintax for accessing variables is as follows:

${VARIABLE} 

but in some cases, especially when you are trying to access the variables used during assembly, this syntax can be used:

 ${ENV, var="VARIABLE"} 

This in my case also works when you have a parameterized assembly.

0
source share

Assembly parameters are access as $ Name in the Execution section and post-assembly. you can use

 $JOB_NAME $BUILD_NUMBER 

for the job name and build number, which matches the name JOB_ID.

Also set "Jenkins user build variables" to get more information about environment variables.

0
source share

All Articles