close

How to execute local python scripts in Jenkins UI

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How to execute local python scripts in Jenkins UI in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How to execute local python scripts in Jenkins UI?

  1. How to execute local python scripts in Jenkins UI?

    instead of handle local script file on each server, you can actually copy all the python script into the “execute shell” under the Build section. it has to start with the relevant python shebang. For example:

  2. execute local python scripts in Jenkins UI

    instead of handle local script file on each server, you can actually copy all the python script into the “execute shell” under the Build section. it has to start with the relevant python shebang. For example:

Method 1

Create a Jenkins job and run your scripts as shell script from jenkins job. Like this

#!/bin/sh
python <absolute_path_of_python_script>.py

Method 2

instead of handle local script file on each server, you can actually copy all the python script into the “execute shell” under the Build section. it has to start with the relevant python shebang. For example:

#!/usr/bin/env python
your script...

you can also add parameters in the job and use environment variables in your python script. for example

parameter1 = os.environ['parameter1']

Summery

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read