diff --git a/jenkins_jobs/modules/parameters.py b/jenkins_jobs/modules/parameters.py index 36f7db00a..17fbf713e 100644 --- a/jenkins_jobs/modules/parameters.py +++ b/jenkins_jobs/modules/parameters.py @@ -74,6 +74,36 @@ def string_param(parser, xml_parent, data): 'hudson.model.StringParameterDefinition') +def promoted_param(parser, xml_parent, data): + """yaml: promoted build + A promoted build parameter. + Requires the Jenkins :jenkins-wiki:`Promoted Builds Plugin + `. + + :arg str name: the name of the parameter (required) + :arg str project-name: the job from which the user can pick runs (required) + :arg str promotion-name: promotion process to choose from (optional) + :arg str description: a description of the parameter (optional) + + Example: + + .. literalinclude:: + /../../tests/parameters/fixtures/promoted-build-param001.yaml + :language: yaml + + """ + pdef = base_param(parser, xml_parent, data, False, + 'hudson.plugins.promoted__builds.parameters.' + 'PromotedBuildParameterDefinition') + try: + XML.SubElement(pdef, 'projectName').text = data['project-name'] + except KeyError: + raise MissingAttributeError('project-name') + + XML.SubElement(pdef, 'promotionProcessName').text = data.get( + 'promotion-name', None) + + def password_param(parser, xml_parent, data): """yaml: password A password parameter. diff --git a/tests/parameters/fixtures/promoted-build-param001.xml b/tests/parameters/fixtures/promoted-build-param001.xml new file mode 100644 index 000000000..909f73b3b --- /dev/null +++ b/tests/parameters/fixtures/promoted-build-param001.xml @@ -0,0 +1,15 @@ + + + + + + + FOO + Select a foo-build for promotion + foo-build + passed-promotion + + + + + diff --git a/tests/parameters/fixtures/promoted-build-param001.yaml b/tests/parameters/fixtures/promoted-build-param001.yaml new file mode 100644 index 000000000..7f87c02da --- /dev/null +++ b/tests/parameters/fixtures/promoted-build-param001.yaml @@ -0,0 +1,6 @@ +parameters: + - promoted: + name: FOO + project-name: "foo-build" + promotion-name: "passed-promotion" + description: "Select a foo-build for promotion" diff --git a/tests/parameters/fixtures/promoted-build-param002.xml b/tests/parameters/fixtures/promoted-build-param002.xml new file mode 100644 index 000000000..6419aff2a --- /dev/null +++ b/tests/parameters/fixtures/promoted-build-param002.xml @@ -0,0 +1,15 @@ + + + + + + + FOO + + foo-build + + + + + + diff --git a/tests/parameters/fixtures/promoted-build-param002.yaml b/tests/parameters/fixtures/promoted-build-param002.yaml new file mode 100644 index 000000000..98d40d664 --- /dev/null +++ b/tests/parameters/fixtures/promoted-build-param002.yaml @@ -0,0 +1,4 @@ +parameters: + - promoted: + name: FOO + project-name: "foo-build"