diff --git a/jenkins_jobs/modules/wrappers.py b/jenkins_jobs/modules/wrappers.py index 7c75b4b4e..76255cd4e 100644 --- a/jenkins_jobs/modules/wrappers.py +++ b/jenkins_jobs/modules/wrappers.py @@ -2180,6 +2180,55 @@ def artifactory_maven_freestyle(parser, xml_parent, data): artifactory_optional_props(artifactory, data, 'wrappers') +def maven_release(parser, xml_parent, data): + """yaml: maven-release + Wrapper for Maven projects + Requires :jenkins-wiki:`M2 Release Plugin ` + + :arg str release-goals: Release goals and options (default '') + :arg str dry-run-goals: DryRun goals and options (default '') + :arg int num-successful-builds: Number of successful release builds to keep + (default 1) + :arg bool select-custom-scm-comment-prefix: Preselect 'Specify custom SCM + comment prefix' (default false) + :arg bool select-append-jenkins-username: Preselect 'Append Jenkins + Username' (default false) + :arg bool select-scm-credentials: Preselect 'Specify SCM login/password' + (default false) + :arg str release-env-var: Release environment variable (default '') + :arg str scm-user-env-var: SCM username environment variable (default '') + :arg str scm-password-env-var: SCM password environment variable + (default '') + + Example: + + .. literalinclude:: /../../tests/wrappers/fixtures/maven-release001.yaml + :language: yaml + + """ + mvn_release = XML.SubElement(xml_parent, + 'org.jvnet.hudson.plugins.m2release.' + 'M2ReleaseBuildWrapper') + XML.SubElement(mvn_release, 'releaseGoals').text = str( + data.get('release-goals', '')) + XML.SubElement(mvn_release, 'dryRunGoals').text = str( + data.get('dry-run-goals', '')) + XML.SubElement(mvn_release, 'numberOfReleaseBuildsToKeep').text = str( + data.get('num-successful-builds', '1')) + XML.SubElement(mvn_release, 'selectCustomScmCommentPrefix').text = str( + data.get('select-custom-scm-comment-prefix', 'false')).lower() + XML.SubElement(mvn_release, 'selectAppendHudsonUsername').text = str( + data.get('select-append-jenkins-username', 'false')).lower() + XML.SubElement(mvn_release, 'selectScmCredentials').text = str( + data.get('select-scm-credentials', 'false')).lower() + XML.SubElement(mvn_release, 'releaseEnvVar').text = str( + data.get('release-env-var', '')) + XML.SubElement(mvn_release, 'scmUserEnvVar').text = str( + data.get('scm-user-env-var', '')) + XML.SubElement(mvn_release, 'scmPasswordEnvVar').text = str( + data.get('scm-password-env-var', '')) + + class Wrappers(jenkins_jobs.modules.base.Base): sequence = 80 diff --git a/tests/wrappers/fixtures/maven-release001.xml b/tests/wrappers/fixtures/maven-release001.xml new file mode 100644 index 000000000..9a885ca51 --- /dev/null +++ b/tests/wrappers/fixtures/maven-release001.xml @@ -0,0 +1,16 @@ + + + + + -Dresume=false release:prepare release:perform + -Dresume=false -DdryRun=true release:prepare + 1 + false + false + false + IS_M2RELEASEBUILD + SCM_USER + + + + diff --git a/tests/wrappers/fixtures/maven-release001.yaml b/tests/wrappers/fixtures/maven-release001.yaml new file mode 100644 index 000000000..02f3afb1d --- /dev/null +++ b/tests/wrappers/fixtures/maven-release001.yaml @@ -0,0 +1,10 @@ +wrappers: + - maven-release: + release-goals: -Dresume=false release:prepare release:perform + dry-run-goals: -Dresume=false -DdryRun=true release:prepare + num-successful-builds: 1 + select-custom-scm-comment-prefix: false + select-append-jenkins-username: false + select-scm-credentials: false + release-env-var: IS_M2RELEASEBUILD + scm-user-env-var: SCM_USER diff --git a/tests/wrappers/fixtures/maven-release002.xml b/tests/wrappers/fixtures/maven-release002.xml new file mode 100644 index 000000000..42941ef3d --- /dev/null +++ b/tests/wrappers/fixtures/maven-release002.xml @@ -0,0 +1,16 @@ + + + + + -Dresume=false release:prepare release:perform + -Dresume=false -DdryRun=true release:prepare + 2 + true + false + true + + SCM_USER + SCM_PASSWORD + + + diff --git a/tests/wrappers/fixtures/maven-release002.yaml b/tests/wrappers/fixtures/maven-release002.yaml new file mode 100644 index 000000000..4102b2ea5 --- /dev/null +++ b/tests/wrappers/fixtures/maven-release002.yaml @@ -0,0 +1,10 @@ +wrappers: + - maven-release: + release-goals: -Dresume=false release:prepare release:perform + dry-run-goals: -Dresume=false -DdryRun=true release:prepare + num-successful-builds: 2 + select-custom-scm-comment-prefix: true + select-append-jenkins-username: false + select-scm-credentials: true + scm-user-env-var: SCM_USER + scm-password-env-var: SCM_PASSWORD