How Jenkins executes Python scripts, and compatibility issues with Python versions

Source: Internet
Author: User
Tags python script

To run a python script on Jenkins, find some common methods, as described below. Also encountered version compatibility issues caused by how all do not succeed, eventually tried various versions, to locate the compatibility issue, is really various pits.

There are generally three ways to do this:
1. Install the Execute Python plugin: Python Plugin, after installation, you can see the following options in the configuration, you can write Python code directly in the script section

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M02/8C/BD/wKiom1h178STxToIAAA1X0Hoalc246.png-wh_500x0-wm_ 3-wmp_4-s_3345051341.png "style=" Float:none; "title=" 1.png "alt=" Wkiom1h178stxtoiaaa1x0hoalc246.png-wh_50 "/>

2. Execute the python script with execute Windows batch command

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M01/8C/BD/wKiom1h178WRWYk-AAAm_aTDbeY607.png-wh_500x0-wm_ 3-wmp_4-s_205639885.png "title=" 2.png "style=" Float:none; alt= "Wkiom1h178wrwyk-aaam_atdbey607.png-wh_50"/>

3. Execute the python script with the Execute shell, and note the start to write #!python.exe

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M01/8C/BA/wKioL1h178XwFuGUAAAg-BVcp98973.png-wh_500x0-wm_ 3-wmp_4-s_3857685635.png "title=" 3.png "style=" Float:none; alt= "Wkiol1h178xwfuguaaag-bvcp98973.png-wh_50"/>

The above three methods need to install the Python environment on the machine where Jenkins is built, and add a global variable for the Python installation path in Jenkins's system, and the key name tries to write "Python" or "path" OK.

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M02/8C/BD/wKiom1h178WAXivFAAAmERFlieE547.png-wh_500x0-wm_ 3-wmp_4-s_590888002.png "title=" 4.png "style=" Float:none; alt= "Wkiom1h178waxivfaaamerfliee547.png-wh_50"/>

The actual use of the problem is: in the environment I set up more than three start only the second can be performed successfully, and later installed Envinject Plugin The second method of execution is not possible after the plugin.

Error prompt to execute:

The error that is performed with the first method is shown in the following picture:

650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M02/8C/BA/wKioL1h178aj33oRAADYOStN9Xg958.png-wh_500x0-wm_ 3-wmp_4-s_889128049.png "title=" 5.png "style=" Float:none; alt= "Wkiol1h178aj33oraadyostn9xg958.png-wh_50"/>

Error hints executed in the second method the following, I have been stuck in the line that I framed, do not return, the figure is I manually returned.

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M00/8C/BD/wKiom1h178bDFqijAABsztCQiV8094.png-wh_500x0-wm_ 3-wmp_4-s_3056764537.png "title=" 6.png "style=" Float:none; alt= "Wkiom1h178bdfqijaabsztcqiv8094.png-wh_50"/>

Repeated trials to find the cause of the problem, and then began to troubleshoot problems, my system environment is as follows:

Jenkins version: 2.7.1

Python environment: 3.6.0 (Python-3.6.0-amd64.exe)

1. Suspected Python installs the number of package bit problem:

Because Jenkins is installed under Program Files (x86), it starts to wonder if there is a problem with the number of bits of Python's installation package, and whether the 32-bit Python should be installed. Before uninstalling the Python environment, a python3.5.1 32-bit installation package was installed and the results are still not working.

2. I use Jenkins is not the latest version, doubt whether the support of Python3 is not good.

After uninstalling the previous version of Python with the 2.7.8 version installed, running the Python script in 3 ways works correctly. But remember to add a Python installation path to your system settings.


This article is from the "ntting" blog, make sure to keep this source http://ntting.blog.51cto.com/12385331/1891132

How Jenkins executes Python scripts, and compatibility issues with Python versions

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.