From 44048fa9112bd02e59b3670712ad651b4e7cd32e Mon Sep 17 00:00:00 2001 From: Juha Kallioinen Date: Sat, 9 Dec 2023 20:01:40 +0200 Subject: [PATCH 1/2] fix: return changeset items correctly from a pipeline build Fixes #748 Jenkins pipeline build returns a list of changesets instead of a single changeset dict. --- jenkinsapi/build.py | 7 +++++-- jenkinsapi_tests/unittests/configs.py | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/jenkinsapi/build.py b/jenkinsapi/build.py index 3134d521..4a156f73 100644 --- a/jenkinsapi/build.py +++ b/jenkinsapi/build.py @@ -149,8 +149,11 @@ def get_changeset_items(self): if "items" in self._data["changeSet"]: return self._data["changeSet"]["items"] elif "changeSets" in self._data: - if "items" in self._data["changeSets"]: - return self._data["changeSets"]["items"] + changes = [] + for change in self._data["changeSets"]: + if "items" in change: + changes += change["items"] + return changes return [] def _get_vcs(self) -> str: diff --git a/jenkinsapi_tests/unittests/configs.py b/jenkinsapi_tests/unittests/configs.py index 9f604770..9721a918 100644 --- a/jenkinsapi_tests/unittests/configs.py +++ b/jenkinsapi_tests/unittests/configs.py @@ -168,7 +168,7 @@ "artifacts": [], "building": False, "builtOn": "localhost", - "changeSets": { + "changeSets": [{ "items": [ { "affectedPaths": ["content/rcm/v00-rcm-xccdf.xml"], @@ -188,7 +188,7 @@ } ], "kind": None, - }, + }], "culprits": [], "description": "Best build ever!", "duration": 5782, From 98518d34b0c36617fd6f6cd0535406b9f2b756bf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 9 Dec 2023 18:15:49 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- jenkinsapi_tests/unittests/configs.py | 47 +++++++++++++++------------ 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/jenkinsapi_tests/unittests/configs.py b/jenkinsapi_tests/unittests/configs.py index 9721a918..7698bca9 100644 --- a/jenkinsapi_tests/unittests/configs.py +++ b/jenkinsapi_tests/unittests/configs.py @@ -168,27 +168,32 @@ "artifacts": [], "building": False, "builtOn": "localhost", - "changeSets": [{ - "items": [ - { - "affectedPaths": ["content/rcm/v00-rcm-xccdf.xml"], - "author": { - "absoluteUrl": "http://jenkins_url/user/username79", - "fullName": "username", - }, - "commitId": "3097", - "timestamp": 1414398423091, - "date": "2014-10-27T08:27:03.091288Z", - "msg": "commit message", - "paths": [ - {"editType": "edit", "file": "/some/path/of/changed_file"} - ], - "revision": 3097, - "user": "username", - } - ], - "kind": None, - }], + "changeSets": [ + { + "items": [ + { + "affectedPaths": ["content/rcm/v00-rcm-xccdf.xml"], + "author": { + "absoluteUrl": "http://jenkins_url/user/username79", + "fullName": "username", + }, + "commitId": "3097", + "timestamp": 1414398423091, + "date": "2014-10-27T08:27:03.091288Z", + "msg": "commit message", + "paths": [ + { + "editType": "edit", + "file": "/some/path/of/changed_file", + } + ], + "revision": 3097, + "user": "username", + } + ], + "kind": None, + } + ], "culprits": [], "description": "Best build ever!", "duration": 5782,