From 5548ac51d7ceae9c7563d56636bc1d76881e3cea Mon Sep 17 00:00:00 2001 From: Lucas Dutra Nunes Date: Mon, 27 Jun 2016 17:43:29 -0300 Subject: [PATCH] Properties: fix copyartifact permissions with several projects The copyartifacts property on Jenkins requires that the config XML provide an string element for each allowed project. On JJB the documentation says that the projects needed only to be comma-separated, however JJB is not doing the job separation. Parsing the projects string, spliting it by commas and then adding it to a different string element solves this. Change-Id: I59d8b2c070f28df4cfa9da0ab58f2c57e4243384 Signed-off-by: Lucas Dutra Nunes --- jenkins_jobs/modules/properties.py | 3 ++- tests/properties/fixtures/copyartifact-multiple.xml | 11 +++++++++++ tests/properties/fixtures/copyartifact-multiple.yaml | 3 +++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 tests/properties/fixtures/copyartifact-multiple.xml create mode 100644 tests/properties/fixtures/copyartifact-multiple.yaml diff --git a/jenkins_jobs/modules/properties.py b/jenkins_jobs/modules/properties.py index 88e3f18c7..f66536312 100644 --- a/jenkins_jobs/modules/properties.py +++ b/jenkins_jobs/modules/properties.py @@ -507,7 +507,8 @@ def copyartifact(parser, xml_parent, data): raise JenkinsJobsException("projects string must exist and " "not be empty") projectlist = XML.SubElement(copyartifact, 'projectNameList') - XML.SubElement(projectlist, 'string').text = data.get('projects') + for project in str(data.get('projects')).split(','): + XML.SubElement(projectlist, 'string').text = project def batch_tasks(parser, xml_parent, data): diff --git a/tests/properties/fixtures/copyartifact-multiple.xml b/tests/properties/fixtures/copyartifact-multiple.xml new file mode 100644 index 000000000..ac46e518a --- /dev/null +++ b/tests/properties/fixtures/copyartifact-multiple.xml @@ -0,0 +1,11 @@ + + + + + + foo* + bar + + + + diff --git a/tests/properties/fixtures/copyartifact-multiple.yaml b/tests/properties/fixtures/copyartifact-multiple.yaml new file mode 100644 index 000000000..d0f3f9389 --- /dev/null +++ b/tests/properties/fixtures/copyartifact-multiple.yaml @@ -0,0 +1,3 @@ +properties: + - copyartifact: + projects: foo*,bar