Registry / devops / python-jenkins

python-jenkins

JSON →
library1.8.3pypypi✓ verified 35d ago

Python-jenkins is a Python client library for the Jenkins Remote API, allowing programmatic interaction with Jenkins CI/CD servers. It provides methods to manage jobs, builds, nodes, plugins, and users. The current version is 1.8.3, and it receives maintenance releases roughly annually.

devops
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

from jenkins import Jenkins

For proper error handling and connection issues.

from jenkins import JenkinsException

This quickstart demonstrates how to connect to a Jenkins instance using environment variables for credentials (preferring API tokens), retrieve the current user and Jenkins version, and list existing jobs. It includes basic error handling for connection and API issues.

import jenkins import os # Configure Jenkins connection details using environment variables for security JENKINS_URL = os.environ.get('JENKINS_URL', 'http://localhost:8080') JENKINS_USER = os.environ.get('JENKINS_USER', 'admin') JENKINS_API_TOKEN = os.environ.get('JENKINS_API_TOKEN', 'your_jenkins_api_token') # Prefer API token over password try: # Initialize the Jenkins client server = jenkins.Jenkins(JENKINS_URL, username=JENKINS_USER, password=JENKINS_API_TOKEN) # Get basic information user_info = server.get_whoami() jenkins_version = server.get_version() print(f'Connected to Jenkins {jenkins_version} as {user_info["fullName"]}') # List jobs jobs = server.get_jobs() print(f'Found {len(jobs)} jobs. First 5 job names:') for job in jobs[:5]: print(f'- {job["name"]}') except jenkins.JenkinsException as e: print(f"Error connecting to or interacting with Jenkins: {e}") except Exception as e: print(f"An unexpected error occurred: {e}")
Debug
Known footguns
deprecatedPrefer Jenkins API tokens over user passwords for authentication.
gotchaSSL certificate verification can fail with self-signed or corporate certificates.
gotchaConnection and API errors are raised as `jenkins.JenkinsException`.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
0 hits · last 30 days

No traffic data recorded yet.

Resources