Add partial support for maven-release-plugin
This patch adds support for the Maven release build wrapper. The Maven release plugin makes use of the concept of jenkins Actions to trigger the actual release - https://wiki.jenkins-ci.org/display/JENKINS/Action+and+its+family+of+subtypes The actual code for the action - https://github.com/jenkinsci/m2release-plugin/blob/master/ src/main/java/org/jvnet/hudson/plugins/m2release/M2ReleaseAction.java, seems to put together all the required parameters and makes a call to scheduleBuild2 and passes an Action object with it. Afaik, JJB doesn't support the concept of Actions. If the M2ReleaseAction was an instance of Builder, instead of Action it would work with this. Currently, I don't see how the actual build (release) can be triggered from JJB config, and it seems like we can define the build wrapper alone as part of the job definition, and would still have to trigger the release from the UI for the job like - <jobname>/m2release Change-Id: Ifc979cdb8e40ad31debff04f745649f23f7ef91a
This commit is contained in:
parent
77dcacb071
commit
f74501e781
@ -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 <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
|
||||
|
||||
|
16
tests/wrappers/fixtures/maven-release001.xml
Normal file
16
tests/wrappers/fixtures/maven-release001.xml
Normal file
@ -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>
|
10
tests/wrappers/fixtures/maven-release001.yaml
Normal file
10
tests/wrappers/fixtures/maven-release001.yaml
Normal file
@ -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
|
16
tests/wrappers/fixtures/maven-release002.xml
Normal file
16
tests/wrappers/fixtures/maven-release002.xml
Normal file
@ -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>
|
10
tests/wrappers/fixtures/maven-release002.yaml
Normal file
10
tests/wrappers/fixtures/maven-release002.yaml
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user