Add support for the random string parameter
Change-Id: I4aa49e32e7c1628fb0bb7c587e0060d5b601dd35
This commit is contained in:
parent
0ece25ced4
commit
2e377ba3af
@ -783,6 +783,35 @@ def hidden_param(parser, xml_parent, data):
|
|||||||
'com.wangyin.parameter.WHideParameterDefinition')
|
'com.wangyin.parameter.WHideParameterDefinition')
|
||||||
|
|
||||||
|
|
||||||
|
def random_string_param(registry, xml_parent, data):
|
||||||
|
"""yaml: random-string
|
||||||
|
This parameter generates a random string and passes it to the
|
||||||
|
build, preventing Jenkins from combining queued builds.
|
||||||
|
Requires the Jenkins :jenkins-wiki:`Random String Parameter Plugin
|
||||||
|
<Random+String+Parameter+Plugin>`.
|
||||||
|
|
||||||
|
:arg str name: Name of the parameter
|
||||||
|
:arg str description: Description of the parameter (default '')
|
||||||
|
:arg str failed-validation-message: Failure message to display for invalid
|
||||||
|
input (default '')
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
.. literalinclude::
|
||||||
|
/../../tests/parameters/fixtures/random-string-param001.yaml
|
||||||
|
:language: yaml
|
||||||
|
"""
|
||||||
|
pdef = XML.SubElement(xml_parent,
|
||||||
|
'hudson.plugins.random__string__parameter.'
|
||||||
|
'RandomStringParameterDefinition')
|
||||||
|
if 'name' not in data:
|
||||||
|
raise JenkinsJobsException('random-string must have a name parameter.')
|
||||||
|
XML.SubElement(pdef, 'name').text = data['name']
|
||||||
|
XML.SubElement(pdef, 'description').text = data.get('description', '')
|
||||||
|
XML.SubElement(pdef, 'failedValidationMessage').text = data.get(
|
||||||
|
'failed-validation-message', '')
|
||||||
|
|
||||||
|
|
||||||
class Parameters(jenkins_jobs.modules.base.Base):
|
class Parameters(jenkins_jobs.modules.base.Base):
|
||||||
sequence = 21
|
sequence = 21
|
||||||
|
|
||||||
|
14
tests/parameters/fixtures/random-string-param001.xml
Normal file
14
tests/parameters/fixtures/random-string-param001.xml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<project>
|
||||||
|
<properties>
|
||||||
|
<hudson.model.ParametersDefinitionProperty>
|
||||||
|
<parameterDefinitions>
|
||||||
|
<hudson.plugins.random__string__parameter.RandomStringParameterDefinition>
|
||||||
|
<name>job-string</name>
|
||||||
|
<description>A random string passed to the job</description>
|
||||||
|
<failedValidationMessage>Your input string is invalid</failedValidationMessage>
|
||||||
|
</hudson.plugins.random__string__parameter.RandomStringParameterDefinition>
|
||||||
|
</parameterDefinitions>
|
||||||
|
</hudson.model.ParametersDefinitionProperty>
|
||||||
|
</properties>
|
||||||
|
</project>
|
5
tests/parameters/fixtures/random-string-param001.yaml
Normal file
5
tests/parameters/fixtures/random-string-param001.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
parameters:
|
||||||
|
- random-string:
|
||||||
|
name: job-string
|
||||||
|
description: "A random string passed to the job"
|
||||||
|
failed-validation-message: "Your input string is invalid"
|
Loading…
x
Reference in New Issue
Block a user