diff options
-rw-r--r-- | jenkins_jobs/modules/wrappers.py | 49 | ||||
-rw-r--r-- | tests/wrappers/fixtures/maven-release001.xml | 16 | ||||
-rw-r--r-- | tests/wrappers/fixtures/maven-release001.yaml | 10 | ||||
-rw-r--r-- | tests/wrappers/fixtures/maven-release002.xml | 16 | ||||
-rw-r--r-- | tests/wrappers/fixtures/maven-release002.yaml | 10 |
5 files changed, 101 insertions, 0 deletions
diff --git a/jenkins_jobs/modules/wrappers.py b/jenkins_jobs/modules/wrappers.py index 22333904..9e1ed857 100644 --- a/jenkins_jobs/modules/wrappers.py +++ b/jenkins_jobs/modules/wrappers.py @@ -2287,6 +2287,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 <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 00000000..9a885ca5 --- /dev/null +++ b/tests/wrappers/fixtures/maven-release001.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8"?> +<project> + <buildWrappers> + <org.jvnet.hudson.plugins.m2release.M2ReleaseBuildWrapper> + <releaseGoals>-Dresume=false release:prepare release:perform</releaseGoals> + <dryRunGoals>-Dresume=false -DdryRun=true release:prepare</dryRunGoals> + <numberOfReleaseBuildsToKeep>1</numberOfReleaseBuildsToKeep> + <selectCustomScmCommentPrefix>false</selectCustomScmCommentPrefix> + <selectAppendHudsonUsername>false</selectAppendHudsonUsername> + <selectScmCredentials>false</selectScmCredentials> + <releaseEnvVar>IS_M2RELEASEBUILD</releaseEnvVar> + <scmUserEnvVar>SCM_USER</scmUserEnvVar> + <scmPasswordEnvVar/> + </org.jvnet.hudson.plugins.m2release.M2ReleaseBuildWrapper> + </buildWrappers> +</project> diff --git a/tests/wrappers/fixtures/maven-release001.yaml b/tests/wrappers/fixtures/maven-release001.yaml new file mode 100644 index 00000000..02f3afb1 --- /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 00000000..42941ef3 --- /dev/null +++ b/tests/wrappers/fixtures/maven-release002.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8"?> +<project> + <buildWrappers> + <org.jvnet.hudson.plugins.m2release.M2ReleaseBuildWrapper> + <releaseGoals>-Dresume=false release:prepare release:perform</releaseGoals> + <dryRunGoals>-Dresume=false -DdryRun=true release:prepare</dryRunGoals> + <numberOfReleaseBuildsToKeep>2</numberOfReleaseBuildsToKeep> + <selectCustomScmCommentPrefix>true</selectCustomScmCommentPrefix> + <selectAppendHudsonUsername>false</selectAppendHudsonUsername> + <selectScmCredentials>true</selectScmCredentials> + <releaseEnvVar/> + <scmUserEnvVar>SCM_USER</scmUserEnvVar> + <scmPasswordEnvVar>SCM_PASSWORD</scmPasswordEnvVar> + </org.jvnet.hudson.plugins.m2release.M2ReleaseBuildWrapper> + </buildWrappers> +</project> diff --git a/tests/wrappers/fixtures/maven-release002.yaml b/tests/wrappers/fixtures/maven-release002.yaml new file mode 100644 index 00000000..4102b2ea --- /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 |