Python API for managing jobs and nodes in a Jenkins CI instance
Go to file
Evgeni Golov b147d86446 only change view name from all to All when All was requested
Otherwise you get errors like:

    Traceback (most recent call last):
      File "path/bin/jenkins-jobs", line 8, in <module>
        sys.exit(main())
                 ^^^^^^
      File "path/lib64/python3.12/site-packages/jenkins_jobs/cli/entry.py", line 179, in main
        jjb.execute()
      File "path/lib64/python3.12/site-packages/jenkins_jobs/cli/entry.py", line 158, in execute
        ext.obj.execute(self.options, self.jjb_config)
      File "path/lib64/python3.12/site-packages/jenkins_jobs/cli/subcommand/update.py", line 154, in execute
        n = builder.delete_old_managed_views(keep=keep_views)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "path/lib64/python3.12/site-packages/jenkins_jobs/builder.py", line 402, in delete_old_managed_views
        if view["name"] not in keep and self.is_view(view["name"], use_cache=False):
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "path/lib64/python3.12/site-packages/jenkins_jobs/builder.py", line 384, in is_view
        return self.jenkins.view_exists(view_name)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "path/lib64/python3.12/site-packages/jenkins/__init__.py", line 1857, in view_exists
        if self.get_view_name(name) == name:
           ^^^^^^^^^^^^^^^^^^^^^^^^
      File "path/lib64/python3.12/site-packages/jenkins/__init__.py", line 1834, in get_view_name
        raise JenkinsException(
    jenkins.JenkinsException: Jenkins returned an unexpected view name All (expected: all)

Fixes: a8f0d8cfda
Change-Id: I82b5abd8429190e871e432732d502b0640ebc99b
Signed-off-by: Evgeni Golov <evgeni@golov.de>
2024-05-10 13:18:59 +02:00
doc Adopt use of pre-commit hooks 2018-06-22 13:37:30 +01:00
jenkins only change view name from all to All when All was requested 2024-05-10 13:18:59 +02:00
tests get_build_artifact_as_bytes to support non-json files 2023-10-14 14:52:56 +00:00
.coveragerc Use standard cover setup 2016-12-20 22:17:24 +01:00
.gitignore Replace testr with stestr 2018-04-04 23:25:21 +01:00
.gitreview OpenDev Migration Patch 2019-04-19 19:49:46 +00:00
.pre-commit-config.yaml Adopt use of pre-commit hooks 2018-06-22 13:37:30 +01:00
.stestr.conf Replace testr with stestr 2018-04-04 23:25:21 +01:00
.zuul.yaml CI: add support to python 37 to 311 2023-07-17 14:17:35 +00:00
bindep.txt Fix CI tests 2023-03-16 21:06:36 +01:00
COPYING Added tags 2011-06-30 17:54:54 +01:00
MANIFEST.in Add MANIFEST.in 2014-08-22 11:29:08 -05:00
README.rst Switch links for contributors to opendev.org or launchpad 2020-08-01 09:27:53 +02:00
requirements.txt Fix compatibility with setuptools >= 66 2023-10-19 15:42:27 +00:00
setup.cfg Switch links for contributors to opendev.org or launchpad 2020-08-01 09:27:53 +02:00
setup.py Use pbr, pep8 checks & fixes, add "doc" tox target 2014-07-02 14:12:31 -07:00
test-requirements.txt CI: add support to python 37 to 311 2023-07-17 14:17:35 +00:00
tox.ini CI: add support to python 37 to 311 2023-07-17 14:17:35 +00:00

README

Python Jenkins is a python wrapper for the Jenkins REST API which aims to provide a more conventionally pythonic way of controlling a Jenkins server. It provides a higher-level API containing a number of convenience functions.

We like to use python-jenkins to automate our Jenkins servers. Here are some of the things you can use it for:

  • Create new jobs
  • Copy existing jobs
  • Delete jobs
  • Update jobs
  • Get a job's build information
  • Get Jenkins master version information
  • Get Jenkins plugin information
  • Start a build on a job
  • Create nodes
  • Enable/Disable nodes
  • Get information on nodes
  • Create/delete/reconfig views
  • Put server in shutdown mode (quiet down)
  • List running builds
  • Delete builds
  • Wipeout job workspace
  • Create/delete/update folders1
  • Set the next build number2
  • Install plugins
  • and many more..

To install:

$ sudo python setup.py install

Online documentation:

Developers

Bug report:

Repository:

Cloning:

Patches are submitted via Gerrit at:

Please do not submit GitHub pull requests, they will be automatically closed.

The python-jenkins developers communicate in the #openstack-jjb channel on Freenode's IRC network.

More details on how you can contribute is available on our wiki at:

Writing a patch

Be sure that you lint code before created an code review. The easiest way to do this is to install git pre-commit hooks.

Installing without setup.py

Then install the required python packages using pip:

$ sudo pip install python-jenkins

Footnotes


  1. The free Cloudbees Folders Plugin provides support for a subset of the full folders functionality. For the complete capabilities you will need the paid for version of the plugin.↩︎

  2. The Next Build Number Plugin provides support for setting the next build number.↩︎