I am new to Jenkins and Python. I have jenkings test build Project with build parameters. Below is the screen shot for reference.
ScreenShot of build Parameters
I need to Pass this inputs to python script "test.py"
My execute command is looks like below:
/usr/bin/python2.7 /scripts/test.py
test.py script:
import time
import os
input1 = os.getenv("input1")
input2 = os.getenv("input2")
Dropdown = os.getenv("Dropdown1")
Dropdown2 = os.getenv("Dropdown2")
print input1
print input2
print Dropdown
print Dropdown2
Console output:
Building in workspace /root/.jenkins/workspace/Inputs-Test
[Inputs-Test] $ /bin/sh -xe /tools/apache-tomcat-8.5.24/temp/jenkins3261310337115825812.sh
+ /usr/bin/python2.7 /project/test.py
None
None
None
None
Finished: SUCCESS
Since those parameters are part of the environment of the Jenkins created process you are always able to access them in the following way.
import os
input1 = os.getenv("Input1")
input2 = os.getenv("input2")
Dropdown = os.getenv("Dropdown")
Dropdown2 = os.getenv("dropdown2")
Now set those in your setupClass or your test setup method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With