From 44048fa9112bd02e59b3670712ad651b4e7cd32e Mon Sep 17 00:00:00 2001 From: Juha Kallioinen Date: Sat, 9 Dec 2023 20:01:40 +0200 Subject: [PATCH] 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,