Adding Maven3 Builder Targets

Adding ability to use maven3 builder targets within your build.
This is a change to the builders.py file to add the new
functionality (similar to top-level maven targets).

Change-Id: I63367bc6c51f4dafce1287eca2438f04472e1c5b
This commit is contained in:
Dawid Malinowski 2015-05-02 19:50:31 +02:00
parent e4f77fe06c
commit 09d541564e
4 changed files with 52 additions and 0 deletions

View File

@ -1076,6 +1076,41 @@ def conditional_step(parser, xml_parent, data):
build_step(steps_parent, step)
def maven_builder(parser, xml_parent, data):
"""yaml: maven-builder
Execute Maven3 builder
:arg str name: Name of maven installation from the configuration
:arg str pom: Location of pom.xml (default 'pom.xml')
:arg str goals: Goals to execute
:arg str maven-opts: Additional options for maven (optional)
Requires the Jenkins `Artifactory Plugin
<https://wiki.jenkins-ci.org/display/JENKINS/Artifactory+Plugin>`_
allows your build jobs to deploy artifacts automatically to Artifactory.
Example:
.. literalinclude:: /../../tests/builders/fixtures/maven-builder001.yaml
:language: yaml
"""
maven = XML.SubElement(xml_parent, 'org.jfrog.hudson.maven3.Maven3Builder')
required = {
'mavenName': 'name',
'goals': 'goals',
}
for key in required:
try:
XML.SubElement(maven, key).text = data[required[key]]
except KeyError:
raise MissingAttributeError(required[key])
XML.SubElement(maven, 'rootPom').text = data.get('pom', 'pom.xml')
XML.SubElement(maven, 'mavenOpts').text = data.get('maven-opts', '')
def maven_target(parser, xml_parent, data):
"""yaml: maven-target
Execute top-level Maven targets

View File

@ -62,6 +62,7 @@ jenkins_jobs.builders =
groovy=jenkins_jobs.modules.builders:groovy
inject=jenkins_jobs.modules.builders:inject
managed-script=jenkins_jobs.modules.builders:managed_script
maven-builder=jenkins_jobs.modules.builders:maven_builder
maven-target=jenkins_jobs.modules.builders:maven_target
msbuild=jenkins_jobs.modules.builders:msbuild
multijob=jenkins_jobs.modules.builders:multijob

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<builders>
<org.jfrog.hudson.maven3.Maven3Builder>
<mavenName>mvn3</mavenName>
<goals>clean install</goals>
<rootPom>modules/pom.xml</rootPom>
<mavenOpts/>
</org.jfrog.hudson.maven3.Maven3Builder>
</builders>
</project>

View File

@ -0,0 +1,5 @@
builders:
- maven-builder:
name: mvn3
pom: modules/pom.xml
goals: clean install