Jenkins Python Plugin
Official Wiki:https://wiki.jenkins-ci.org/display/jenkins/python+plugin
It makes it possible to execute Python scripts at build time (provided that Python must already be added to the PATH environment variable)
Of course, it can also use a series of environment variables provided by JENKINS, such as: Build_number build_id job_name jenkins_home, etc.
These environment variables can be clicked on the following links to view details, http://ip[:p ort]/jenkins/env-vars.html/
So how do you use these environment variables?
Taking Build_number as an example,
Use this environment variable in the Windows batch command, use%build_number% to
Use this environment variable in the Linux shell command, use ${build_number} to
To use this environment variable in a Python script, you need a specific code implementation, as follows:
Import Osprint os.getenv ("Build_number")
To perform this build, the output is as follows:
Jenkins Python plugin Get environment variables