pyjen.jenkins module
Primitives for interacting with the main Jenkins dashboard
- class pyjen.jenkins.Jenkins(url, session)[source]
Bases:
object
Python wrapper managing the Jenkins primary dashboard
Generally you should use this class as the primary entry point to the PyJen APIs. Finer grained control of each aspect of the Jenkins dashboard is then provided by the objects exposed by this class including
View
,Job
andBuild
.- Parameters
url (str) – URL of the Jenkins service to connect to
session (requests.Session) – pre-configured HTTP session to use for communicating to the Jenkins REST API. This session may be user defined, or built using one of the factory methods associated with this class such as
basic_auth()
.
- property all_jobs
all jobs managed by this Jenkins instance, recursively
Unlike the
jobs()
method, this method attempts to expose jobs which are managed by custom jobs created from third party plugins which support nesting jobs under sub-folders / sub-paths. Any job which exposes a custom ‘jobs’ property.
- classmethod basic_auth(url, credentials=None, ssl_cert=None)[source]
Factory method used to instantiate a connection to a Jenkins server using HTTP basic auth protocol
- Parameters
url (str) – Full HTTP URL to the main Jenkins dashboard
credentials (tuple) – Optional 2-tuple containing the username and password / api key to authenticate with. If not provided, anonymous access will be assumed
ssl_cert (str) – Passed directly to the requests library when authenticating to the remote server. Maybe be a boolean indicating whether SSL verification is enabled or disabled, or may be a path to a certificate authority bundle.
- Returns
instance of this class, preconfigured to connect to the specified Jenkins service using an HTTP basic auth connection
- Return type
- cancel_shutdown()[source]
Cancels a previous scheduled shutdown sequence
Cancels a shutdown operation initiated by the
prepare_shutdown()
method
- create_view(view_name, view_class)[source]
Creates a new view on the Jenkins dashboard
- Parameters
view_name (str) – The name for this new view. This name should be unique, different from any other views currently managed by the Jenkins instance
view_class – PyJen plugin class associated with the type of view to be created
- Returns
An object to manage the newly created view
- Return type
- property default_view
the primary / default Jenkins view
The default view is the one displayed when navigating to the main URL. Typically this will be the “All” view, but this may be customized by the user at runtime.
- Type
- find_job(job_name)[source]
Searches all jobs managed by this Jenkins instance for a specific job
Some plugins allow jobs to be nested within other jobs. To perform a recursive search across all such entities, see
all_jobs()
.
- property is_shutting_down
True if the Jenkins master is scheduled for a shutdown, False if not
- Type
- property plugin_manager
interface for managing the plugins installed on this Jenkins instance
- Type
- prepare_shutdown()[source]
Starts a “quiet down” and prevents new builds from executing
Analogous to the “Prepare for Shutdown” link on the Manage Jenkins configuration page
You can cancel a previous requested shutdown using the
cancel_shutdown()
method