Create one parameters wrapper tag for all release params
Ensure only one parameterDefinitions XML tag is created for the entire set of parameters instead of one per parameter. Add a test case to show the correct behaviour with more than one parameter defined and update the docstring to use the yaml test case as an exmaple. While updating the docstring add missing default values for arguments. Change-Id: Ife8f2535117d355d845d5d72dd9e6e6669a6b9df
This commit is contained in:
parent
df37b9b7c7
commit
a2f47f9e3b
@ -648,27 +648,17 @@ def release(parser, xml_parent, data):
|
|||||||
|
|
||||||
:arg bool keep-forever: Keep build forever (default true)
|
:arg bool keep-forever: Keep build forever (default true)
|
||||||
:arg bool override-build-parameters: Enable build-parameter override
|
:arg bool override-build-parameters: Enable build-parameter override
|
||||||
:arg string version-template: Release version template
|
(default false)
|
||||||
|
:arg string version-template: Release version template (default '')
|
||||||
:arg list parameters: Release parameters (see the :ref:`Parameters` module)
|
:arg list parameters: Release parameters (see the :ref:`Parameters` module)
|
||||||
:arg list pre-build: Pre-build steps (see the :ref:`Builders` 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-build: Post-build steps (see :ref:`Builders`)
|
||||||
:arg list post-success: Post successful-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`)
|
:arg list post-failed: Post failed-build steps (see :ref:`Builders`)
|
||||||
|
|
||||||
Example::
|
Example:
|
||||||
|
|
||||||
wrappers:
|
.. literalinclude:: /../../tests/wrappers/fixtures/release001.yaml
|
||||||
- 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,
|
relwrap = XML.SubElement(xml_parent,
|
||||||
@ -683,11 +673,11 @@ def release(parser, xml_parent, data):
|
|||||||
data.get('override-build-parameters', False)).lower()
|
data.get('override-build-parameters', False)).lower()
|
||||||
XML.SubElement(relwrap, 'releaseVersionTemplate').text = data.get(
|
XML.SubElement(relwrap, 'releaseVersionTemplate').text = data.get(
|
||||||
'version-template', '')
|
'version-template', '')
|
||||||
for param in data.get('parameters', []):
|
parameters = data.get('parameters', [])
|
||||||
parser.registry.dispatch('parameter', parser,
|
if parameters:
|
||||||
XML.SubElement(relwrap,
|
pdef = XML.SubElement(relwrap, 'parameterDefinitions')
|
||||||
'parameterDefinitions'),
|
for param in parameters:
|
||||||
param)
|
parser.registry.dispatch('parameter', parser, pdef, param)
|
||||||
|
|
||||||
builder_steps = {
|
builder_steps = {
|
||||||
'pre-build': 'preBuildSteps',
|
'pre-build': 'preBuildSteps',
|
||||||
|
29
tests/wrappers/fixtures/release001.xml
Normal file
29
tests/wrappers/fixtures/release001.xml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<project>
|
||||||
|
<buildWrappers>
|
||||||
|
<hudson.plugins.release.ReleaseWrapper>
|
||||||
|
<doNotKeepLog>true</doNotKeepLog>
|
||||||
|
<overrideBuildParameters>false</overrideBuildParameters>
|
||||||
|
<releaseVersionTemplate/>
|
||||||
|
<parameterDefinitions>
|
||||||
|
<hudson.model.StringParameterDefinition>
|
||||||
|
<name>RELEASE_BRANCH</name>
|
||||||
|
<description>Git branch to release from.</description>
|
||||||
|
<defaultValue/>
|
||||||
|
</hudson.model.StringParameterDefinition>
|
||||||
|
<hudson.model.BooleanParameterDefinition>
|
||||||
|
<name>FOO</name>
|
||||||
|
<description>A parameter named FOO, defaults to 'false'.</description>
|
||||||
|
<defaultValue>false</defaultValue>
|
||||||
|
</hudson.model.BooleanParameterDefinition>
|
||||||
|
</parameterDefinitions>
|
||||||
|
<postSuccessfulBuildSteps>
|
||||||
|
<hudson.tasks.Shell>
|
||||||
|
<command>#!/bin/bash
|
||||||
|
copy_build_artefacts.sh
|
||||||
|
</command>
|
||||||
|
</hudson.tasks.Shell>
|
||||||
|
</postSuccessfulBuildSteps>
|
||||||
|
</hudson.plugins.release.ReleaseWrapper>
|
||||||
|
</buildWrappers>
|
||||||
|
</project>
|
16
tests/wrappers/fixtures/release001.yaml
Normal file
16
tests/wrappers/fixtures/release001.yaml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
wrappers:
|
||||||
|
- release:
|
||||||
|
keep-forever: false
|
||||||
|
parameters:
|
||||||
|
- string:
|
||||||
|
name: RELEASE_BRANCH
|
||||||
|
default: ''
|
||||||
|
description: Git branch to release from.
|
||||||
|
- bool:
|
||||||
|
name: FOO
|
||||||
|
default: false
|
||||||
|
description: "A parameter named FOO, defaults to 'false'."
|
||||||
|
post-success:
|
||||||
|
- shell: |
|
||||||
|
#!/bin/bash
|
||||||
|
copy_build_artefacts.sh
|
Loading…
Reference in New Issue
Block a user