Utils

crumb_requester module

class jenkinsapi.utils.crumb_requester.CrumbRequester(*args, **kwargs)[source]

Bases: Requester

Adapter for Requester inserting the crumb in every request.

post_url(url, params=None, data=None, files=None, headers=None, allow_redirects=True, **kwargs)[source]

docker_jenkins module

Docker-based Jenkins instance manager for testing.

class jenkinsapi.utils.docker_jenkins.DockerJenkins(image_name: str = 'jenkinsapi-systest:latest', container_name: str = 'jenkinsapi-systest', port: int = 8080, jenkins_home: str | None = None)[source]

Bases: object

Manage a Jenkins instance running in Docker.

build_image(dockerfile_path: str = 'docker/Dockerfile') None[source]
dump_plugin_versions(output_file: str = 'plugin_versions.txt') str[source]
get_logs(lines: int = 100) str[source]
restart_jenkins_service(timeout: int = 60) None[source]
start(timeout: int = 300) None[source]
stop() None[source]
wait_for_ready(timeout: int = 300) None[source]
exception jenkinsapi.utils.docker_jenkins.DockerJenkinsError[source]

Bases: Exception

Raised when Docker-backed Jenkins setup or control fails.

jsonp_to_json module

Module for converting jsonp to json.

jenkinsapi.utils.jsonp_to_json.jsonp_to_json(jsonp)[source]

krb_requester module

Kerberos aware Requester

class jenkinsapi.utils.krb_requester.KrbRequester(*args, **kwargs)[source]

Bases: Requester

A class which carries out HTTP requests with Kerberos/GSSAPI authentication.

get_request_dict(params=None, data=None, files=None, headers=None, **kwargs)[source]

manifest module

This module enables Manifest file parsing. Copied from https://chromium.googlesource.com/external/googleappengine/python/+/master /google/appengine/tools/jarfile.py

exception jenkinsapi.utils.manifest.InvalidJarError[source]

Bases: Exception

InvalidJar exception class

class jenkinsapi.utils.manifest.Manifest(main_section, sections)[source]

Bases: object

The parsed manifest from a jar file. Attributes:

main_section: a dict representing the main (first)

section of the manifest. Each key is a string that is an attribute, such as ‘Manifest-Version’, and the corresponding value is a string that is the value of the attribute, such as ‘1.0’.

sections: a dict representing the other sections of the manifest.

Each key is a string that is the value of the ‘Name’ attribute for the section, and the corresponding value is a dict like the main_section one, for the other attributes.

jenkinsapi.utils.manifest.read_manifest(jar_file_name)[source]

Read and parse the manifest out of the given jar. Args:

jar_file_name: the name of the jar from which the manifest is to be read.

Returns:

A parsed Manifest object, or None if the jar has no manifest.

Raises:

IOError: if the jar does not exist or cannot be read.

requester module

Module for jenkinsapi requester (which is a wrapper around python-requests)

class jenkinsapi.utils.requester.Requester(*args, **kwargs)[source]

Bases: object

A class which carries out HTTP requests. You can replace this class with one of your own implementation if you require some other way to access Jenkins.

This default class can handle simple authentication only.

VALID_STATUS_CODES = [200]
get_and_confirm_status(url, params=None, headers=None, valid=None, stream=False)[source]
get_request_dict(params=None, data=None, files=None, headers=None, **kwargs)[source]
get_url(url, params=None, headers=None, allow_redirects=True, stream=False)[source]
post_and_confirm_status(url, params=None, data=None, files=None, headers=None, valid=None, allow_redirects=True)[source]
post_url(url, params=None, data=None, files=None, headers=None, allow_redirects=True, **kwargs)[source]
post_xml_and_confirm_status(url, params=None, data=None, valid=None)[source]

logging module

Helpers for configuring JenkinsAPI logging without clobbering user settings.

jenkinsapi.utils.logging.configure_logging(level: str | int | None = None) bool[source]

Configure JenkinsAPI logging if the user hasn’t already.

If level is None, the environment variable JENKINSAPI_LOG_LEVEL is used. Returns True when logging was configured.

simple_post_logger module

class jenkinsapi.utils.simple_post_logger.ServerHandler(*args, directory=None, **kwargs)[source]

Bases: SimpleHTTPRequestHandler

do_GET()[source]

Serve a GET request.

do_POST()[source]

Module contents

Module __init__ for utils