Operations 8 min read

Managing Jenkins Jobs with the python‑jenkins API

This tutorial demonstrates how to install the python‑jenkins library, explore its extensive job, node, credential, view and plugin management methods, and use concrete code examples to create, copy, configure, and control Jenkins jobs and pipelines from Python scripts.

DevOps Cloud Academy
DevOps Cloud Academy
DevOps Cloud Academy
Managing Jenkins Jobs with the python‑jenkins API

This guide introduces the python-jenkins library (available on PyPI) for interacting with a Jenkins server via its REST API using Python 3.7.

Key capabilities include creating, copying, deleting, updating jobs; managing builds, nodes, credentials, views, plugins; retrieving configuration and status information; and performing administrative actions such as quiet‑down and script execution.

Typical workflow starts with installing the library ( pip install python-jenkins==1.6.0 ), creating a Jenkins object, and then calling methods like create_job , copy_job , build_job , etc.

Do‑operations (actions) are grouped in tables in the original article; for example, job operations use methods create_job , disable_job , delete_job , copy_job , enable_job , job_exists , jobs_count , upsert_job . Similar groups exist for builds, credentials, views, nodes, promotions, queue handling, Jenkinsfile syntax checking, and updates.

Get‑operations (queries) include methods such as get_all_jobs , get_job_info , get_build_info , get_credential_info , get_node_info , get_plugin_info , get_version , get_whoami , and others.

Update operations cover actions like quiet_down , reconfig_credential , reconfig_job , reconfig_node , reconfig_view , rename_job , run_script , and set_next_build_number .

Demo example : after creating a sample job, the tutorial shows how to retrieve its config.xml , duplicate the job, and verify creation with server.job_exists("demo-test-02") . It also provides a full script that logs into Jenkins, copies a template job, replaces a parameter value (e.g., changing <defaultValue>svn</defaultValue> to <defaultValue>git</defaultValue> ), and creates a new job.

Running the script produces console output confirming the new job’s existence and displays the generated XML configuration, illustrating how to automate project provisioning in a CI/CD environment.

PythonCI/CDAutomationjob managementpython-jenkinsJenkins API
DevOps Cloud Academy
Written by

DevOps Cloud Academy

Exploring industry DevOps practices and technical expertise.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.