Jenkins Python plugin Get environment variables

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.