Reputation: 817
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?
Upvotes: 0
Views: 843
Reputation: 6824
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%
Upvotes: 1
Reputation: 3076
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
Upvotes: 1