Reputation: 111
a. How would I store unit's MAC address to Jenkins' environment variable so I can pass it to another Python script in the same job?
b. Another solution I am looking at is to write MAC address to a text file during execution of checkoutDevice script, then Jenkins will read that MAC address from the text file to store into a variable then pass to another Python script?
Upvotes: 3
Views: 11076
Reputation: 91
Assuming you're using a recent version of Jenkins, one neat trick is to use Stdout to populate the groovy variable of the Jenkinsfile. Assuming your python script is not too chatty, meaning it only prints to stdOut the value you want to get out of the python script, you can do:
mac = sh(script: 'python checkoutDevice.py',returnStdout: true).trim()
Upvotes: 9
Reputation: 11915
There's no easy way I know of to store the "variable" in jenkins. Your best bet is to use some other place to store this MAC address. A file would be a good place, but it probably needs to be on a shared fileserver somewhere.
Upvotes: 0