Add Release plugin

Add support for a 'release' wrapper section which enables the
Release Plugin
(https://wiki.jenkins-ci.org/display/JENKINS/Release+Plugin).

Change-Id: I48e9cdd3f32c4f7e3da843b6adb58767b357b2e7
Reviewed-on: https://review.openstack.org/31650
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Approved: James E. Blair <corvus@inaugust.com>
Reviewed-by: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins
This commit is contained in:
Manuel Desbonnet 2013-06-04 15:27:04 +01:00 committed by Jenkins
parent e7feab1c34
commit 9bb8d499b1
3 changed files with 92 additions and 0 deletions

View File

@ -363,6 +363,69 @@ def build_user_vars(parser, xml_parent, data):
XML.SubElement(xml_parent, 'org.jenkinsci.plugins.builduser.BuildUser')
def release(parser, xml_parent, data):
"""yaml: release
Add release build configuration
Requires the Jenkins `Release Plugin.
<https://wiki.jenkins-ci.org/display/JENKINS/Release+Plugin>`_
:arg bool keep-forever: Keep build forever (default is 'true')
:arg bool override-build-parameters: Enable build-parameter override
:arg string version-template: Release version template
:arg list parameters: Release parameters (see the :ref:`Parameters` module)
:arg list pre-build: Pre-build steps (see the :ref:`Builders` module)
:arg list post-build: Post-build steps (see :ref:`Builders`)
:arg list post-success: Post successful-build steps (see :ref:`Builders`)
:arg list post-failed: Post failed-build steps (see :ref:`Builders`)
Example::
wrappers:
- release:
keep-forever: false
parameters:
- string:
name: RELEASE_BRANCH
default: ''
description: Git branch to release from.
post-success:
- shell: |
#!/bin/bash
copy_build_artefacts.sh
"""
relwrap = XML.SubElement(xml_parent,
'hudson.plugins.release.ReleaseWrapper')
# For 'keep-forever', the sense of the XML flag is the opposite of
# the YAML flag.
no_keep_forever = 'false'
if str(data.get('keep-forever', 'true')).lower() == 'false':
no_keep_forever = 'true'
XML.SubElement(relwrap, 'doNotKeepLog').text = no_keep_forever
XML.SubElement(relwrap, 'overrideBuildParameters').text = str(
data.get('override-build-parameters', 'false')).lower()
XML.SubElement(relwrap, 'releaseVersionTemplate').text = data.get(
'version-template', '')
for param in data.get('parameters', []):
parser.registry.dispatch('parameter', parser,
XML.SubElement(relwrap,
'parameterDefinitions'),
param)
builder_steps = {
'pre-build': 'preBuildSteps',
'post-build': 'postBuildSteps',
'post-success': 'postSuccessfulBuildSteps',
'post-fail': 'postFailedBuildSteps',
}
for step in builder_steps.keys():
for builder in data.get(step, []):
parser.registry.dispatch('builder', parser,
XML.SubElement(relwrap,
builder_steps[step]),
builder)
class Wrappers(jenkins_jobs.modules.base.Base):
sequence = 80

28
samples/release.yaml Normal file
View File

@ -0,0 +1,28 @@
- job:
name: 'test-release'
wrappers:
- release:
keep-forever: false
override-build-parameters: true
version-template: '${RELEASE_VERSION}'
parameters:
- string:
name: RELEASE_BRANCH
default: ''
description: 'The release branch to build'
pre-build:
- shell: |
#!/bin/bash
echo "echo pre-build builder"
post-build:
- shell: |
#!/bin/bash
echo "echo post-build builder"
post-success:
- shell: |
#!/bin/bash
echo "echo post-success builder"
post-fail:
- shell: |
#!/bin/bash
echo "echo post-fail builder"

View File

@ -161,6 +161,7 @@ setuptools.setup(
'inject=jenkins_jobs.modules.wrappers:inject',
'jclouds=jenkins_jobs.modules.wrappers:jclouds',
'build-user-vars=jenkins_jobs.modules.wrappers:build_user_vars',
'release=jenkins_jobs.modules.wrappers:release',
],
'jenkins_jobs.modules': [
'general=jenkins_jobs.modules.general:General',