From 5acdda5d8579f08ec473f66b5b9f6eca359a13de Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Mon, 19 Jan 2015 21:15:24 -0500 Subject: [PATCH] Add support for M2 repository cleanup plugin https://wiki.jenkins-ci.org/display/JENKINS/M2+Repository+Cleanup+Plugin Change-Id: Ic45c3dde022e2e84b5b31d960d76c8ef1972ee05 Signed-off-by: Thanh Ha --- jenkins_jobs/modules/wrappers.py | 29 +++++++++++++++++++ setup.cfg | 1 + .../fixtures/m2-repository-cleanup001.xml | 12 ++++++++ .../fixtures/m2-repository-cleanup001.yaml | 5 ++++ .../fixtures/m2-repository-cleanup002.xml | 9 ++++++ .../fixtures/m2-repository-cleanup002.yaml | 2 ++ 6 files changed, 58 insertions(+) create mode 100644 tests/wrappers/fixtures/m2-repository-cleanup001.xml create mode 100644 tests/wrappers/fixtures/m2-repository-cleanup001.yaml create mode 100644 tests/wrappers/fixtures/m2-repository-cleanup002.xml create mode 100644 tests/wrappers/fixtures/m2-repository-cleanup002.yaml diff --git a/jenkins_jobs/modules/wrappers.py b/jenkins_jobs/modules/wrappers.py index 10bb0a3e4..89ab19611 100644 --- a/jenkins_jobs/modules/wrappers.py +++ b/jenkins_jobs/modules/wrappers.py @@ -287,6 +287,35 @@ def workspace_cleanup(parser, xml_parent, data): deldirs.text = str(data.get("dirmatch", False)).lower() +def m2_repository_cleanup(parser, xml_parent, data): + """yaml: m2-repository-cleanup + Configure M2 Repository Cleanup + Requires the Jenkins `M2 Repository Cleanup. + `_ + + :arg list patterns: List of patterns for artifacts to cleanup before + building. (optional) + + This plugin allows you to configure a maven2 job to clean some or all of + the artifacts from the repository before it runs. + + Example: + + .. literalinclude:: \ +../../tests/wrappers/fixtures/m2-repository-cleanup001.yaml + """ + m2repo = XML.SubElement( + xml_parent, + 'hudson.plugins.m2__repo__reaper.M2RepoReaperWrapper') + m2repo.set("plugin", "m2-repo-reaper") + patterns = data.get("patterns", []) + XML.SubElement(m2repo, 'artifactPatterns').text = ",".join(patterns) + p = XML.SubElement(m2repo, 'patterns') + for pattern in patterns: + XML.SubElement(p, 'string').text = pattern + + def rvm_env(parser, xml_parent, data): """yaml: rvm-env Set the RVM implementation diff --git a/setup.cfg b/setup.cfg index 95938cc80..434d0e259 100644 --- a/setup.cfg +++ b/setup.cfg @@ -217,6 +217,7 @@ jenkins_jobs.wrappers = locks=jenkins_jobs.modules.wrappers:locks logfilesize=jenkins_jobs.modules.wrappers:logfilesize logstash=jenkins_jobs.modules.wrappers:logstash + m2-repository-cleanup=jenkins_jobs.modules.wrappers:m2_repository_cleanup mask-passwords=jenkins_jobs.modules.wrappers:mask_passwords matrix-tie-parent=jenkins_jobs.modules.wrappers:matrix_tie_parent mongo-db=jenkins_jobs.modules.wrappers:mongo_db diff --git a/tests/wrappers/fixtures/m2-repository-cleanup001.xml b/tests/wrappers/fixtures/m2-repository-cleanup001.xml new file mode 100644 index 000000000..ca5a6028c --- /dev/null +++ b/tests/wrappers/fixtures/m2-repository-cleanup001.xml @@ -0,0 +1,12 @@ + + + + + com/ibm/**,com/microsoft/** + + com/ibm/** + com/microsoft/** + + + + diff --git a/tests/wrappers/fixtures/m2-repository-cleanup001.yaml b/tests/wrappers/fixtures/m2-repository-cleanup001.yaml new file mode 100644 index 000000000..154b8dd72 --- /dev/null +++ b/tests/wrappers/fixtures/m2-repository-cleanup001.yaml @@ -0,0 +1,5 @@ +wrappers: + - m2-repository-cleanup: + patterns: + - com/ibm/** + - com/microsoft/** diff --git a/tests/wrappers/fixtures/m2-repository-cleanup002.xml b/tests/wrappers/fixtures/m2-repository-cleanup002.xml new file mode 100644 index 000000000..fc73c0c6b --- /dev/null +++ b/tests/wrappers/fixtures/m2-repository-cleanup002.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/wrappers/fixtures/m2-repository-cleanup002.yaml b/tests/wrappers/fixtures/m2-repository-cleanup002.yaml new file mode 100644 index 000000000..b09f63438 --- /dev/null +++ b/tests/wrappers/fixtures/m2-repository-cleanup002.yaml @@ -0,0 +1,2 @@ +wrappers: + - m2-repository-cleanup