From 3da732e01eaed2b0d1805cf36b6f22daceb08169 Mon Sep 17 00:00:00 2001 From: Joao Vale Date: Wed, 20 Apr 2016 00:12:15 +0100 Subject: [PATCH] Add Promoted Build parameter. Change-Id: Ic995976a9c2596c8579963512e20a44087641dce Co-Authored-By: Steven Armstrong --- jenkins_jobs/modules/parameters.py | 30 +++++++++++++++++++ .../fixtures/promoted-build-param001.xml | 15 ++++++++++ .../fixtures/promoted-build-param001.yaml | 6 ++++ .../fixtures/promoted-build-param002.xml | 15 ++++++++++ .../fixtures/promoted-build-param002.yaml | 4 +++ 5 files changed, 70 insertions(+) create mode 100644 tests/parameters/fixtures/promoted-build-param001.xml create mode 100644 tests/parameters/fixtures/promoted-build-param001.yaml create mode 100644 tests/parameters/fixtures/promoted-build-param002.xml create mode 100644 tests/parameters/fixtures/promoted-build-param002.yaml 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"