简体   繁体   中英

How to send Jenkins build number as parameter in shell command which will get executed after build ends

i am running a python script every time, after a Jenkins build fails or gets aborted. In that script i want to pass the Build Number so that i have this info in the script and use it accordingly.

Can someone help me please to understand how i should pass this build number as parameter to my shell command?

py-postbuild 编号

You shoud use "Execute Windows Batch Command" if you access enviornment variable using % .
Using "Execute Windows Batch Command" you can use as below:

echo %BUILD_NUMBER%
C:\\Python38\\python.exe C:\\python-workspace\\hello_test.py %BUILD_NUMBER%

If you want to execute with shell then you can access using $ as $BUILD_NUMBER

You are using the Postbuild Task plugin which executes the script as a shell script, and therefore you should use the shell parameter syntax which is $YOUR_PARAM

In your case just update your code to use $BUILD_NUMBER instead of %BUILD_NUMBER%

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM