Python Job Runner

  • Azure Pipelines can run parallel Tox test jobs to split up the work. On a development computer, you have to run your test environments in series. This sample uses tox -e py to run whichever version of Python is active for the current job.
  • With Python there’s always a lot of libraries and options for solving any particular problem and running scheduled or recurring jobs is no exception. Whether you want to run simple deferred task, bunch of scheduled jobs or manage cron tabs, there’s specialized library for that in Python.
Python job runners

Without a doubt, Python has become one of the best programming languages to learn if you want to upskill your career. Here are six careers that are perfect for job applicants with Python skills. Python Developer. Becoming a Python developer is the most direct job out there for someone who knows the Python programming language.

Read Time: 2mins

In this article, I will explain how you can trigger a Jenkins job remotely from a Python script. There would be situations when you want to run a particular Jenkins job from a Python scripts remotely. The steps are very easy. Let’s get started.

Step 1: Setup the Jenkins Job to be triggered remotely.

Go to the Jenkins job and Click Configure button.

Under Build Triggers Section, check box for Trigger builds remotely (e.g., from scripts) and add an Authentication Token . An authentication token is required to make sure not everybody can trigger your job. You can generate a random token from here.

In the above screenshot, you can see the URL to trigger the build is shown in the descriptions. We will use this url in the Python script to trigger the job.

Step 2: Write Python script to trigger job remotely.

Python

I have already written the Python script to trigger a Jenkins job remotely. Here you go.

Just copy/paste the code to your box and give proper values to the variables given below.

jenkins_job_name = Give your Jenkins job name as a string Jenkins_url = Give your Jenkins URL as a string. jenkins_user = Give the Jenkins username as string jenkins_pwd = Give the Jenkins password as string buildWithParameters = Give boolean True if your Jenkins job has parameters, else False. jenkins_params = This variable accepts dictionary. The value of Python Job Runner token should be the authentication token you generated in the step1. If your Jenkins job is parameterised, add the parameters as key/value in this dictionary.

Python Job Runner Online

If you also want to check the build status of the Jenkins job using Python script, read this article.

Python Job Runner Download

Congratulations, you can now trigger your Jenkins from a Python script! Thanks for the time taken to read my blog.

Subscribe to this blog so that you don’t miss out anything useful (Checkout Right Sidebar for the Subscription Form and Facebook follow button) . Please also put your thoughts as comments .