From 733cf8813ca1311a085de92741d6751f918db5fa Mon Sep 17 00:00:00 2001 From: csteiner Date: Fri, 29 Dec 2023 17:21:19 -0600 Subject: [PATCH 01/14] Readme Updates: Remove redundant words, move install and example to top * Removed shell formatting from examples to allow users to directly copy and paste * Gave venv example a name and location * Turned hyperlinks into proper links * Remove requirements plugin, domain is for sale --- README.rst | 101 +++++++++++++++++++++++------------------------------ 1 file changed, 43 insertions(+), 58 deletions(-) diff --git a/README.rst b/README.rst index b6386ce8..7fc11722 100644 --- a/README.rst +++ b/README.rst @@ -10,66 +10,45 @@ jenkinsapi .. image:: https://codecov.io/gh/pycontribs/jenkinsapi/branch/master/graph/badge.svg :target: https://codecov.io/gh/pycontribs/jenkinsapi -.. image:: https://requires.io/github/pycontribs/jenkinsapi/requirements.png?branch=master - :target: https://requires.io/github/pycontribs/jenkinsapi/requirements/?branch=master - :alt: Requirements Status - About this library ------------------- Jenkins is the market leading continuous integration system, originally created by Kohsuke Kawaguchi. -Jenkins (and It's predecessor Hudson) are useful projects for automating common development tasks (e.g. unit-testing, production batches) - but they are somewhat Java-centric. Thankfully the designers have provided an excellent and complete REST interface. This library wraps up that interface as more conventional python objects in order to make many Jenkins oriented tasks easier to automate. - -This library allows you to automate most common Jenkins operations using Python, such as: +Jenkins (and its predecessor Hudson) are useful projects for automating common development tasks (e.g. unit-testing, production batches) - but they are somewhat Java-centric. +| Jenkinsapi makes scripting Jenkins tasks a breeze by wrapping the REST api into familiar python objects. +| Here is a list of some of the most commonly used functionality -* Ability to add/remove/query Jenkins jobs -* Ability to execute jobs and: +* Add, remove, and query Jenkins jobs +* Control pipeline execution * Query the results of a completed build * Block until jobs are complete or run jobs asyncronously * Get objects representing the latest builds of a job -* Work with build artifacts: +* Artifact management * Search for artifacts by simple criteria * Install artifacts to custom-specified directory structures -* Ability to search for builds by source code revision -* Ability to add/remove/query: - * Slaves (Webstart and SSH slaves) +* Search for builds by source code revision +* Create, destroy, and monitor + * Build nodes (Webstart and SSH slaves) * Views (including nested views using NestedViews Jenkins plugin) * Credentials (username/password and ssh key) -* Username/password auth support for jenkins instances with auth turned on -* Ability to script jenkins installation including plugins - -For a full documentation spec of what this library supports see: http://jenkinsapi.readthedocs.io/en/latest/index.html +* Authentication support for username and password +* Manage jenkins and plugin installation -Python versions ---------------- +Full library capabilities are outlined in the `Documentation `_ -The project has been tested against Python versions: - -* 2.7 - last version compatible with Python 2.7 is tagged Py2 in repository and available on PyPi as version 0.3.13 -* 3.8 - 3.11 - -Jenkins versions ----------------- - -Project tested on both stable (LTS) and latest Jenkins versions. Known issues ------------ * Job deletion operations fail unless Cross-Site scripting protection is disabled. - -For other issues, please refer to the support URL below. +| For other issues, please refer to the `support URL `_ Important Links --------------- - -Support and bug-reports: https://github.com/pycontribs/jenkinsapi/issues?direction=desc&sort=comments&state=open - -Project source code: github: https://github.com/pycontribs/jenkinsapi - -Project documentation: https://jenkinsapi.readthedocs.org/en/latest/ - -Releases: http://pypi.python.org/pypi/jenkinsapi +* `Support and bug-reports `_ +* `Source Code `_ +* `Documentation `_ +* `Releases `_ Installation ------------- @@ -111,20 +90,14 @@ JenkinsAPI is intended to map the objects in Jenkins (e.g. Builds, Views, Jobs) .. code-block:: python - >>> import jenkinsapi - >>> from jenkinsapi.jenkins import Jenkins - >>> J = Jenkins('http://localhost:8080') - >>> J.version - 1.542 - >>> J.keys() # Jenkins objects appear to be dict-like, mapping keys (job-names) to - ['foo', 'test_jenkinsapi'] - >>> J['test_jenkinsapi'] - - >>> J['test_jenkinsapi'].get_last_good_build() - - ... - -More examples available on Github: https://github.com/pycontribs/jenkinsapi/tree/master/examples + from jenkinsapi.jenkins import Jenkins + J = Jenkins('http://localhost:8080') + print(J.version) # 1.542 + print(J.keys()) # foo, test_jenkinsapi + print(J.get('test_jenkinsapi')) # + print(J.get('test_jenkinsapi').get_last_good_build()) # + +More examples available on `Github `_ Testing ------- @@ -141,10 +114,10 @@ missing test dependencies: .. code-block:: bash - virtualenv - source .venv/bin/active - (.venv) pip install -r requirements.txt - (.venv) python setup.py test + python -m venv ./.venv/jenkinsapi + source .venv/jenkinsapi/bin/activate + pip install -r requirements.txt + python setup.py test Development ----------- @@ -156,14 +129,26 @@ Development .. code-block:: bash - (.venv) pip install -r test-requirements.txt + pip install -r test-requirements.txt * Make your changes, write tests and check your code .. code-block:: bash - (.venv) pytest + pytest -sv + +Python versions +--------------- + +The project has been tested against Python versions: + +* 3.8 - 3.11 +* 2.7 - last version compatible with Python 2.7 is tagged Py2 in repository and available on PyPi as version 0.3.13 +Jenkins versions +---------------- + +Project tested on both stable (LTS) and latest Jenkins versions. Project Contributors -------------------- From 7669d0e41fc566457dc07b0ae30198503c553cca Mon Sep 17 00:00:00 2001 From: CJ Steiner Date: Fri, 20 Dec 2024 06:22:37 -0600 Subject: [PATCH 02/14] ci: fix issue causing runner to crash in setup * caused by harden runner issues * set-output step also has been deprecated in github actions commit 1e4e57c6c2fc25948cced37e30d62ffe0743a931 Author: csteiner <47841949+clintonsteiner@users.noreply.github.com> Date: Wed Dec 18 05:59:54 2024 -0600 Update python-package.yml commit e6cb694404424940f715ef48924b7aa36672feca Author: csteiner <47841949+clintonsteiner@users.noreply.github.com> Date: Wed Dec 18 05:58:12 2024 -0600 Update python-package.yml commit 0404295c9c2b751a1f86a299a009bbd781a88fbd Author: csteiner <47841949+clintonsteiner@users.noreply.github.com> Date: Wed Dec 18 05:52:50 2024 -0600 Update python-package.yml commit a237595c992228cf18f64640561c90186a1ccb25 Author: csteiner <47841949+clintonsteiner@users.noreply.github.com> Date: Wed Dec 18 05:51:27 2024 -0600 Update python-package.yml commit 634edf75eead461a766ea3157e464135d9ad99ed Author: csteiner <47841949+clintonsteiner@users.noreply.github.com> Date: Wed Dec 18 05:48:28 2024 -0600 Update python-package.yml --- .github/workflows/python-package.yml | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 14e7ee03..e5fbb075 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -11,10 +11,7 @@ on: - '**.yml' pull_request: branches: [ "master" ] - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + workflow_dispatch: # allow manual run jobs: build: @@ -28,7 +25,7 @@ jobs: steps: - name: Harden Runner - uses: step-security/harden-runner@1f99358870fe1c846a3ccba386cc2b2246836776 # v2.2.1 + uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1 with: egress-policy: block allowed-endpoints: > @@ -39,6 +36,8 @@ jobs: ftp-nyc.osuosl.org:443 get.jenkins.io:443 github.com:443 + api.github.com:443 + int.api.stepsecurity.io:443 mirror.xmission.com:443 motd.ubuntu.com:443 packages.microsoft.com:443 @@ -55,23 +54,7 @@ jobs: uses: actions/setup-python@v3 with: python-version: ${{ matrix.python-version }} - - - name: Get pip cache dir - id: pip-cache - run: | - echo "::set-output name=dir::$(pip cache dir)" - - - name: Setup the Pip cache - uses: actions/cache@v3 - with: - path: ${{ steps.pip-cache.outputs.dir }} - key: >- - ${{ matrix.python-version }}-pip-${{ hashFiles('setup.cfg') }}-${{ - hashFiles('setup.py') }}-${{ hashFiles('tox.ini') }}-${{ - hashFiles('.pre-commit-config.yaml') }} - restore-keys: | - ${{ matrix.python-version }}-pip- - ${{ matrix.python-version }}- + cache: 'pip' # caching pip dependencies - name: Install dependencies run: | From 3aa16562a46da28c12b55fb65e34494067522100 Mon Sep 17 00:00:00 2001 From: CJ Steiner Date: Fri, 20 Dec 2024 06:23:02 -0600 Subject: [PATCH 03/14] makefile: fix py.test according to pytest documentation commit d05a7157fe1863bb23e3e9117ad0bc459b027ab0 Author: CJ Steiner Date: Wed Dec 18 06:38:16 2024 -0600 fix Makefile: py.test was deprecated in 2016 in favor of pytest --- Makefile | 4 ++-- jenkinsapi_tests/unittests/test_build.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index fd547c78..b3dec4eb 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ .PHONY: test lint tox coverage dist test: - py.test -sv jenkinsapi_tests + pytest -sv jenkinsapi_tests lint: pycodestyle @@ -14,4 +14,4 @@ dist: python setup.py sdist bdist_wheel coverage: - py.test -sv --cov=jenkinsapi --cov-report=term-missing --cov-report=xml jenkinsapi_tests + pytest -sv --cov=jenkinsapi --cov-report=term-missing --cov-report=xml jenkinsapi_tests diff --git a/jenkinsapi_tests/unittests/test_build.py b/jenkinsapi_tests/unittests/test_build.py index a53c439c..97db35ec 100644 --- a/jenkinsapi_tests/unittests/test_build.py +++ b/jenkinsapi_tests/unittests/test_build.py @@ -3,6 +3,7 @@ import pytz from . import configs import datetime +import warnings from typing import List from jenkinsapi.build import Build from jenkinsapi.job import Job @@ -275,10 +276,9 @@ def fake_get_data(cls, tree=None, params=None): monkeypatch.setattr(Build, "get_data", fake_get_data) with pytest.raises(Exception) as excinfo: - with pytest.warns(None) as record: + with warnings.catch_warnings(): build.get_env_vars() assert "" == str(excinfo.value) - assert len(record) == 0 def test_build_get_status(build) -> None: From 1f719afcbb42c215f3e3886b653e6f121a7178ce Mon Sep 17 00:00:00 2001 From: CJ Steiner Date: Fri, 20 Dec 2024 06:24:38 -0600 Subject: [PATCH 04/14] ci: tests fail because jenkins requires java 17 - setup in github action --- .github/workflows/python-package.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index e5fbb075..100ee2b5 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -56,6 +56,12 @@ jobs: python-version: ${{ matrix.python-version }} cache: 'pip' # caching pip dependencies + - name: setup java 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: Install dependencies run: | sudo apt-get update; sudo apt-get install gcc libkrb5-dev From d09c1601ca0f77a6be84a750f12155470f9889f8 Mon Sep 17 00:00:00 2001 From: CJ Steiner Date: Fri, 20 Dec 2024 06:25:01 -0600 Subject: [PATCH 05/14] test_build: fix failing tests --- jenkinsapi_tests/unittests/test_build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkinsapi_tests/unittests/test_build.py b/jenkinsapi_tests/unittests/test_build.py index 97db35ec..37fae50e 100644 --- a/jenkinsapi_tests/unittests/test_build.py +++ b/jenkinsapi_tests/unittests/test_build.py @@ -259,7 +259,7 @@ def fake_get_data(cls, tree=None, params=None): monkeypatch.setattr(Build, "get_data", fake_get_data) with pytest.raises(requests.HTTPError) as excinfo: - with pytest.warns(None) as record: + with pytest.warns(UserWarning) as record: build.get_env_vars() assert "404" == str(excinfo.value) assert len(record) == 1 From 770a93b672d35ce129407f8d3d613629866880ae Mon Sep 17 00:00:00 2001 From: CJ Steiner Date: Fri, 20 Dec 2024 06:44:10 -0600 Subject: [PATCH 06/14] ci: add mirrors to harden whitelist --- .github/workflows/python-package.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 100ee2b5..adbfe744 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -45,6 +45,7 @@ jobs: pypi.org:443 updates.jenkins-ci.org:80 updates.jenkins.io:443 + mirrors.updates.jenkins.io:443 updates.jenkins.io:80 - name: Checkout From dccedc9a83f2e0c6b3265146ec872d1ff5c945b2 Mon Sep 17 00:00:00 2001 From: CJ Steiner Date: Fri, 20 Dec 2024 06:56:20 -0600 Subject: [PATCH 07/14] ci: harden runner - set to audit for now --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index adbfe744..18d66fd1 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -27,7 +27,7 @@ jobs: - name: Harden Runner uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1 with: - egress-policy: block + egress-policy: audit allowed-endpoints: > azure.archive.ubuntu.com:80 esm.ubuntu.com:443 From b7b6262034d84a4a125eda9607713068b0a14885 Mon Sep 17 00:00:00 2001 From: CJ Steiner Date: Fri, 20 Dec 2024 07:28:07 -0600 Subject: [PATCH 08/14] ci: add in missing plugins --- jenkinsapi_tests/systests/conftest.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jenkinsapi_tests/systests/conftest.py b/jenkinsapi_tests/systests/conftest.py index 1ca2960a..d5cf871f 100644 --- a/jenkinsapi_tests/systests/conftest.py +++ b/jenkinsapi_tests/systests/conftest.py @@ -16,6 +16,7 @@ "http://updates.jenkins.io/latest/" "apache-httpcomponents-client-4-api.hpi", "http://updates.jenkins.io/latest/jsch.hpi", + "http://updates.jenkins.io/latest/gson-api.hpi", "http://updates.jenkins.io/latest/trilead-api.hpi", "http://updates.jenkins.io/latest/workflow-api.hpi", "http://updates.jenkins.io/latest/display-url-api.hpi", @@ -25,7 +26,9 @@ "http://updates.jenkins.io/latest/script-security.hpi", "http://updates.jenkins.io/latest/matrix-project.hpi", "http://updates.jenkins.io/latest/credentials.hpi", + "http://updates.jenkins.io/latest/variant.hpi", "http://updates.jenkins.io/latest/ssh-credentials.hpi", + "http://updates.jenkins.io/latest/asm-api.hpi", "http://updates.jenkins.io/latest/scm-api.hpi", "http://updates.jenkins.io/latest/mailer.hpi", "http://updates.jenkins.io/latest/git.hpi", @@ -43,6 +46,7 @@ "http://updates.jenkins.io/latest/caffeine-api.hpi", "http://updates.jenkins.io/latest/script-security.hpi", "http://updates.jenkins.io/latest/checks-api.hpi", + "http://updates.jenkins.io/latest/json-api.hpi", "http://updates.jenkins.io/latest/jackson2-api.hpi", "http://updates.jenkins.io/latest/bootstrap5-api.hpi", "http://updates.jenkins.io/latest/echarts-api.hpi", From e295f733381728eb8ca1c8bf88e613781caaec41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82?= <45581170+micwoj92@users.noreply.github.com> Date: Tue, 7 Jan 2025 13:31:46 +0100 Subject: [PATCH 09/14] Correctly specify python version (#858) Co-authored-by: csteiner <47841949+clintonsteiner@users.noreply.github.com> --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index dabe7120..78b64424 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,7 @@ classifiers = [ "Topic :: Software Development :: Testing", "Topic :: Utilities", ] -requires_python = ">=2.7" +requires-python = ">=2.7" dynamic = ["version"] dependencies = [ "pytz>=2014.4", From 22614ce3a1f315f927ece3159c4d3f6638f6e4d9 Mon Sep 17 00:00:00 2001 From: csteiner <47841949+clintonsteiner@users.noreply.github.com> Date: Tue, 7 Jan 2025 12:00:03 -0600 Subject: [PATCH 10/14] add support for 3.12 and 3.13 (#877) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .github/workflows/python-package.yml | 4 ++-- README.rst | 7 ++----- doc/source/conf.py | 4 +--- doc/source/index.rst | 5 ++--- jenkinsapi/__init__.py | 6 ------ jenkinsapi/build.py | 3 +-- jenkinsapi/utils/jenkins_launcher.py | 16 +++++++++------- pyproject.toml | 12 +++++------- setup.cfg | 10 ++++------ 9 files changed, 26 insertions(+), 41 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 18d66fd1..46370c89 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -20,8 +20,8 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] - token: ["stable", "latest"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] + token: ["stable"] steps: - name: Harden Runner diff --git a/README.rst b/README.rst index 7fc11722..4380485c 100644 --- a/README.rst +++ b/README.rst @@ -4,9 +4,6 @@ jenkinsapi .. image:: https://badge.fury.io/py/jenkinsapi.png :target: http://badge.fury.io/py/jenkinsapi -.. image:: https://travis-ci.com/pycontribs/jenkinsapi.png?branch=master - :target: https://travis-ci.com/pycontribs/jenkinsapi - .. image:: https://codecov.io/gh/pycontribs/jenkinsapi/branch/master/graph/badge.svg :target: https://codecov.io/gh/pycontribs/jenkinsapi @@ -142,7 +139,7 @@ Python versions The project has been tested against Python versions: -* 3.8 - 3.11 +* 3.8 - 3.13 * 2.7 - last version compatible with Python 2.7 is tagged Py2 in repository and available on PyPi as version 0.3.13 Jenkins versions @@ -177,4 +174,4 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -.. _Java: http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html +.. _Java: https://www.oracle.com/java/technologies/downloads/#java17 diff --git a/doc/source/conf.py b/doc/source/conf.py index 0384b71b..ce71535e 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -13,10 +13,8 @@ # serve to show the default. import logging import jenkinsapi -import pkg_resources -dist = pkg_resources.working_set.by_key[jenkinsapi.__name__] -VERSION = RELEASE = dist.version +VERSION = RELEASE = jenkinsapi.__version__ if __name__ == "__main__": logging.basicConfig() diff --git a/doc/source/index.rst b/doc/source/index.rst index 6389db22..bd79d0b1 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -25,7 +25,6 @@ Sections artifact build using_jenkinsapi - rules_for_contributors Important Links --------------- @@ -53,14 +52,14 @@ Most users can do the following: pip install jenkinsapi -Or.. +Or .. code-block:: bash easy_install jenkinsapi * In Jenkins > 1.518 you will need to disable "Prevent Cross Site Request Forgery exploits". - * Remember to set the Jenkins Location in general settings - Jenkins' REST web-interface will not work if this is set incorrectly. + * Remember to set the Jenkins Location in general settings - Jenkins REST web-interface will not work if this is set incorrectly. Examples -------- diff --git a/jenkinsapi/__init__.py b/jenkinsapi/__init__.py index b4aedb0e..97957b18 100644 --- a/jenkinsapi/__init__.py +++ b/jenkinsapi/__init__.py @@ -93,9 +93,3 @@ __docformat__ = "epytext" # In case of jenkinsapi is not installed in 'develop' mode __version__ = "0.3.13" -try: - import pkg_resources - - __version__ = pkg_resources.working_set.by_key["jenkinsapi"].version -except (ImportError, KeyError): - pass diff --git a/jenkinsapi/build.py b/jenkinsapi/build.py index 3134d521..5e8d97e0 100644 --- a/jenkinsapi/build.py +++ b/jenkinsapi/build.py @@ -527,8 +527,7 @@ def get_estimated_duration(self) -> int | None: def stop(self) -> bool: """ Stops the build execution if it's running - :return boolean True if succeded False otherwise or the build - is not running + :return: boolean True if succeeded False otherwis """ if self.is_running(): url: str = "%s/stop" % self.baseurl diff --git a/jenkinsapi/utils/jenkins_launcher.py b/jenkinsapi/utils/jenkins_launcher.py index 3769194f..9a612ecd 100644 --- a/jenkinsapi/utils/jenkins_launcher.py +++ b/jenkinsapi/utils/jenkins_launcher.py @@ -8,11 +8,10 @@ import requests import queue import threading +import tarfile import subprocess -from pkg_resources import resource_stream from urllib3 import Retry from urllib.parse import urlparse -from tarfile import TarFile from requests.adapters import HTTPAdapter @@ -136,12 +135,15 @@ def update_war(self): ) def update_config(self): - tarball = TarFile.open( - fileobj=resource_stream( - "jenkinsapi_tests.systests", "jenkins_home.tar.gz" - ) + from jenkinsapi_tests import systests + + file = os.path.join( + os.path.dirname(systests.__file__), "jenkins_home.tar.gz" ) - tarball.extractall(path=self.jenkins_home) + + with open(file, "rb") as f: + with tarfile.open(fileobj=f, mode="r:gz") as tarball: + tarball.extractall(path=self.jenkins_home) def install_plugins(self): plugin_dest_dir = os.path.join(self.jenkins_home, "plugins") diff --git a/pyproject.toml b/pyproject.toml index 78b64424..513a55f4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,7 @@ description = "A Python API for accessing resources on a Jenkins continuous-inte readme = "README.rst" license = {text = "MIT license"} classifiers = [ - "Development Status :: 4 - Beta", + "Development Status :: 5 - Production/Stable", "Environment :: Console", "Intended Audience :: Developers", "Intended Audience :: Information Technology", @@ -24,19 +24,17 @@ classifiers = [ "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Topic :: Software Development :: Testing", "Topic :: Utilities", ] -requires-python = ">=2.7" +requires_python = ">=3.8" dynamic = ["version"] dependencies = [ "pytz>=2014.4", diff --git a/setup.cfg b/setup.cfg index f3746251..bebd744c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,7 +6,7 @@ summary = A Python API for accessing resources on a Jenkins continuous-integrati description-file = README.rst license = MIT classifier = - Development Status :: 4 - Beta + Development Status :: 5 - Production/Stable Environment :: Console Intended Audience :: Developers Intended Audience :: Information Technology @@ -16,15 +16,13 @@ classifier = Operating System :: OS Independent Operating System :: OS Independent Programming Language :: Python - Programming Language :: Python :: 2 - Programming Language :: Python :: 2.7 Programming Language :: Python :: 3 - Programming Language :: Python :: 3.4 - Programming Language :: Python :: 3.5 - Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3.12 + Programming Language :: Python :: 3.13 Topic :: Software Development :: Testing Topic :: Utilities From d81867eb6c2dee40af14b8b38a8d22d6693a9c3f Mon Sep 17 00:00:00 2001 From: csteiner <47841949+clintonsteiner@users.noreply.github.com> Date: Tue, 7 Jan 2025 13:39:11 -0600 Subject: [PATCH 11/14] docs: fix build (#876) --- doc/source/conf.py | 1 + doc/source/contributing.rst | 5 +++++ doc/source/index.rst | 7 +------ test-requirements.txt | 1 + 4 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 doc/source/contributing.rst diff --git a/doc/source/conf.py b/doc/source/conf.py index ce71535e..1b1f4148 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -43,6 +43,7 @@ "sphinx.ext.autodoc", "sphinx.ext.doctest", "sphinx.ext.viewcode", + "myst_parser", ] # Add any paths that contain templates here, relative to this directory. diff --git a/doc/source/contributing.rst b/doc/source/contributing.rst new file mode 100644 index 00000000..2232a542 --- /dev/null +++ b/doc/source/contributing.rst @@ -0,0 +1,5 @@ +Contributing +============ + +```{include} ../CONTRIBUTING.md +``` diff --git a/doc/source/index.rst b/doc/source/index.rst index bd79d0b1..58b249c0 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -25,6 +25,7 @@ Sections artifact build using_jenkinsapi + contributing Important Links --------------- @@ -52,12 +53,6 @@ Most users can do the following: pip install jenkinsapi -Or - -.. code-block:: bash - - easy_install jenkinsapi - * In Jenkins > 1.518 you will need to disable "Prevent Cross Site Request Forgery exploits". * Remember to set the Jenkins Location in general settings - Jenkins REST web-interface will not work if this is set incorrectly. diff --git a/test-requirements.txt b/test-requirements.txt index 0d07d562..efc2b376 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -6,6 +6,7 @@ astroid>=1.4.8 pylint>=1.7.1 tox>=2.3.1 mock +myst-parser codecov requests_kerberos flake8 From faa8df1d47322b5e6098c7b7bc1aa3196184406d Mon Sep 17 00:00:00 2001 From: csteiner <47841949+clintonsteiner@users.noreply.github.com> Date: Tue, 7 Jan 2025 13:39:31 -0600 Subject: [PATCH 12/14] ci: remove apt-get update, install, and pip upgrade as unnecessary (#878) --- .github/workflows/python-package.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 46370c89..46df914a 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -65,8 +65,7 @@ jobs: - name: Install dependencies run: | - sudo apt-get update; sudo apt-get install gcc libkrb5-dev - python -m pip install --upgrade pip + sudo apt-get install libkrb5-dev python -m pip install -r test-requirements.txt python -m pip install -r requirements.txt From 9412378b8a8c04cf25a95469ddb377386edb28d3 Mon Sep 17 00:00:00 2001 From: csteiner <47841949+clintonsteiner@users.noreply.github.com> Date: Tue, 7 Jan 2025 14:48:17 -0600 Subject: [PATCH 13/14] ci: update checkout to v4 (#880) --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 46df914a..882bc89b 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -49,7 +49,7 @@ jobs: updates.jenkins.io:80 - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v3 From ff2f305629ea6e7b918660570e7d1825eef5b9cc Mon Sep 17 00:00:00 2001 From: csteiner <47841949+clintonsteiner@users.noreply.github.com> Date: Tue, 7 Jan 2025 14:48:44 -0600 Subject: [PATCH 14/14] convert to uv and pyproject.toml (#879) --- .github/workflows/python-package.yml | 18 ++++++++--------- pyproject.toml | 29 +++++++++++++++++++--------- requirements.txt | 2 -- 3 files changed, 29 insertions(+), 20 deletions(-) delete mode 100644 requirements.txt diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 882bc89b..cabede16 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -6,7 +6,6 @@ name: CI_TEST on: push: paths: - - 'requirements.txt' - '**.py' - '**.yml' pull_request: @@ -51,11 +50,14 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 + - name: Install uv + uses: astral-sh/setup-uv@v5 with: python-version: ${{ matrix.python-version }} - cache: 'pip' # caching pip dependencies + enable-cache: true + + - name: Install python + run: uv python install - name: setup java 17 uses: actions/setup-java@v3 @@ -66,16 +68,14 @@ jobs: - name: Install dependencies run: | sudo apt-get install libkrb5-dev - python -m pip install -r test-requirements.txt - python -m pip install -r requirements.txt - name: Lint with flake8 run: | - flake8 jenkinsapi/ --count --select=E9,F63,F7,F82 --ignore F821,W503,W504 --show-source --statistics - flake8 jenkinsapi/ --count --exit-zero --max-complexity=10 --max-line-length=79 --statistics + uv run flake8 jenkinsapi/ --count --select=E9,F63,F7,F82 --ignore F821,W503,W504 --show-source --statistics + uv run flake8 jenkinsapi/ --count --exit-zero --max-complexity=10 --max-line-length=79 --statistics - name: Test with pytest env: JENKINS_VERSION: ${{ matrix.token }} run: | - pytest -sv --cov=jenkinsapi --cov-report=term-missing --cov-report=xml jenkinsapi_tests + uv run pytest -sv --cov=jenkinsapi --cov-report=term-missing --cov-report=xml jenkinsapi_tests diff --git a/pyproject.toml b/pyproject.toml index 513a55f4..b3418a82 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,19 +34,17 @@ classifiers = [ "Topic :: Software Development :: Testing", "Topic :: Utilities", ] -requires_python = ">=3.8" +requires-python = ">=3.8" dynamic = ["version"] dependencies = [ "pytz>=2014.4", "requests>=2.3.0", - "six>=1.10.0" + "six>=1.10.0", ] -[tool.files] -packages = """ -jenkinsapi -jenkinsapi_utils -jenkinsapi_tests""" +[tool.setuptools] +packages = ["jenkinsapi", "jenkinsapi_utils", "jenkinsapi_tests"] +include-package-data = false [tool.pbr] warnerrors = "True" @@ -70,5 +68,18 @@ universal = 1 exclude = ".tox,doc/source/conf.py,build,.venv,.eggs" max-line-length = "99" -[tool.setuptools] -include-package-data = false +[dependency-groups] +dev = [ + "pytest-mock>=3.14.0", + "pytest>=8.3.4", + "pytest-cov>=4.0.0", + "pycodestyle>=2.3.1", + "astroid>=1.4.8", + "pylint>=1.7.1", + "tox>=2.3.1", + "mock>=5.1.0", + "myst-parser>=3.0.0", + "codecov>=2.1.13", + "requests-kerberos>=0.15.0", + "flake8>=5.0.0", +] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index da330e69..00000000 --- a/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -pytz>=2014.4 -requests>=2.3.0