diff --git a/jenkins_jobs/modules/properties.py b/jenkins_jobs/modules/properties.py index 73b0c6ae5..c11b5d3a1 100644 --- a/jenkins_jobs/modules/properties.py +++ b/jenkins_jobs/modules/properties.py @@ -475,6 +475,36 @@ def build_blocker(parser, xml_parent, data): XML.SubElement(blocker, 'blockingJobs').text = jobs +def copyartifact(parser, xml_parent, data): + """yaml: copyartifact + Specify a list of projects that have access to copy the artifacts of + this project. + + Requires the Jenkins `Copy Artifact plugin. + `_ + + :arg string projects: comma separated list of projects that can copy + artifacts of this project. Wild card character '*' is available. + + + Example: + + .. literalinclude:: \ + /../../tests/properties/fixtures/copyartifact.yaml + + """ + copyartifact = XML.SubElement(xml_parent, + 'hudson.plugins.' + 'copyartifact.' + 'CopyArtifactPermissionProperty', + plugin='copyartifact') + if not data or not data.get('projects', None): + raise JenkinsJobsException("projects string must exist and " + "not be empty") + projectlist = XML.SubElement(copyartifact, 'projectNameList') + XML.SubElement(projectlist, 'string').text = data.get('projects') + + def batch_tasks(parser, xml_parent, data): """yaml: batch-tasks Batch tasks can be tasks for events like releases, integration, archiving, diff --git a/setup.cfg b/setup.cfg index a0fa34a86..a620e03f5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -59,6 +59,7 @@ jenkins_jobs.properties = batch-tasks=jenkins_jobs.modules.properties:batch_tasks build-blocker=jenkins_jobs.modules.properties:build_blocker builds-chain-fingerprinter=jenkins_jobs.modules.properties:builds_chain_fingerprinter + copyartifact=jenkins_jobs.modules.properties:copyartifact delivery-pipeline=jenkins_jobs.modules.properties:delivery_pipeline extended-choice=jenkins_jobs.modules.properties:extended_choice github=jenkins_jobs.modules.properties:github diff --git a/tests/properties/fixtures/copyartifact.xml b/tests/properties/fixtures/copyartifact.xml new file mode 100644 index 000000000..e8cd1f064 --- /dev/null +++ b/tests/properties/fixtures/copyartifact.xml @@ -0,0 +1,10 @@ + + + + + + foo* + + + + diff --git a/tests/properties/fixtures/copyartifact.yaml b/tests/properties/fixtures/copyartifact.yaml new file mode 100644 index 000000000..40f4e9509 --- /dev/null +++ b/tests/properties/fixtures/copyartifact.yaml @@ -0,0 +1,3 @@ +properties: + - copyartifact: + projects: foo*