jenkinsflow.script_api module

class jenkinsflow.script_api.Jenkins(direct_uri, job_prefix_filter=None, username=None, password=None, invocation_class=None, log_dir=None, **kwargs)[source]

Optimized minimal set of methods needed for jenkinsflow to directly execute python code instead of invoking Jenkins jobs.

THIS DOES NOT SUPPORT CONCURRENT INVOCATIONS OF FLOW

There is no concept of job queues or executors, so if your flow depends on these for correctness, you wil experience different behaviour when using this api instead of the real Jenkins.

Parameters:
  • direct_uri (str) –

    Path to dir with ‘job’ method python modules. Modules named <job-name>.py will be imported from this directory. If no module exists for a specific jobname, the module called ‘default.py’ will be imported. The modules must contain at method called ‘run_job’ with the following signature:

    run_job(job_name, job_prefix_filter, username, password, securitytoken, cause, build_params)

    A return value of 0 is ‘SUCCESS’ A return value of 1 or any exception raised is ‘FAILURE’ Other return values means ‘UNSTABLE’

  • job_prefix_filter (str) – Passed to ‘run_job’. jenkinsflow puts no meaning into this parameter.
  • username (str) – Passed to ‘run_job’. jenkinsflow puts no meaning into this parameter.
  • password (str) – Passed to ‘run_job’. jenkinsflow puts no meaning into this parameter.
  • invocation_class (class) – Defaults to Invocation.
  • log_dir (str) – Directory in which to store logs. Defaults to subdirectory ‘jenkinsflow’ under the system defined tmp dir.
  • **kwargs – Ignored for compatibility with the other jenkins apis
set_build_description(description: str, replace: bool = False, separator: str = '\n', build_url: str = None, job_name: str = None, build_number: int = None)[source]

Utility to set/append build description. description will be written to a file in the workspace.

Parameters:
  • description – The description to set on the build.
  • append – If True append to existing description, if any.
  • separator – A separator to insert between any existing description and the new description if append is True.
  • build_url
  • job_name
  • build_number