From 7f853603c535d0de537eedcf62d8524de89d3fcf Mon Sep 17 00:00:00 2001 From: Ken Dreyer Date: Thu, 11 May 2017 16:35:30 -0600 Subject: [PATCH] publishers: add args to gitlab publisher Add support for "Name" and "Mark unstable as success" options. Move the existing gitlab-notifier test to "minimal" and add a "full" test that exercises these new args. Change-Id: I0affb14ac51accf766d930dda816537ceb1d23fc Signed-off-by: Thanh Ha --- jenkins_jobs/modules/publishers.py | 25 ++++++++++++++++--- .../fixtures/gitlab-notifier-full.xml | 9 +++++++ .../fixtures/gitlab-notifier-full.yaml | 4 +++ .../fixtures/gitlab-notifier-minimal.xml | 9 +++++++ ...fier.yaml => gitlab-notifier-minimal.yaml} | 0 tests/publishers/fixtures/gitlab-notifier.xml | 6 ----- 6 files changed, 44 insertions(+), 9 deletions(-) create mode 100644 tests/publishers/fixtures/gitlab-notifier-full.xml create mode 100644 tests/publishers/fixtures/gitlab-notifier-full.yaml create mode 100644 tests/publishers/fixtures/gitlab-notifier-minimal.xml rename tests/publishers/fixtures/{gitlab-notifier.yaml => gitlab-notifier-minimal.yaml} (100%) delete mode 100644 tests/publishers/fixtures/gitlab-notifier.xml diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index e71341882..6db9d225d 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -4389,14 +4389,33 @@ def gitlab_notifier(registry, xml_parent, data): Set build status on GitLab commit. Requires the Jenkins :jenkins-wiki:`GitLab Plugin `. - Example: + :arg str name: The name of the build in GitLab. With this you can + distinguish different Jenkins jobs for the same commit in GitLab. + (default 'jenkins') + :arg bool mark-unstable-as-success: (default false) - .. literalinclude:: /../../tests/publishers/fixtures/gitlab-notifier.yaml + Minimal Example: + + .. literalinclude:: + /../../tests/publishers/fixtures/gitlab-notifier-minimal.yaml + :language: yaml + + Full Example: + + .. literalinclude:: + /../../tests/publishers/fixtures/gitlab-notifier-full.yaml :language: yaml """ - XML.SubElement( + top = XML.SubElement( xml_parent, 'com.dabsquared.gitlabjenkins.publisher.GitLabCommitStatusPublisher') + top.set('plugin', 'gitlab-plugin') + + mappings = [ + ('name', 'name', 'jenkins'), + ('mark-unstable-as-success', 'markUnstableAsSuccess', False), + ] + helpers.convert_mapping_to_xml(top, data, mappings, fail_required=True) def zulip(registry, xml_parent, data): diff --git a/tests/publishers/fixtures/gitlab-notifier-full.xml b/tests/publishers/fixtures/gitlab-notifier-full.xml new file mode 100644 index 000000000..46ef5232a --- /dev/null +++ b/tests/publishers/fixtures/gitlab-notifier-full.xml @@ -0,0 +1,9 @@ + + + + + foobar-jenkins + true + + + diff --git a/tests/publishers/fixtures/gitlab-notifier-full.yaml b/tests/publishers/fixtures/gitlab-notifier-full.yaml new file mode 100644 index 000000000..dc867db31 --- /dev/null +++ b/tests/publishers/fixtures/gitlab-notifier-full.yaml @@ -0,0 +1,4 @@ +publishers: + - gitlab-notifier: + name: foobar-jenkins + mark-unstable-as-success: true diff --git a/tests/publishers/fixtures/gitlab-notifier-minimal.xml b/tests/publishers/fixtures/gitlab-notifier-minimal.xml new file mode 100644 index 000000000..b2bf7eb70 --- /dev/null +++ b/tests/publishers/fixtures/gitlab-notifier-minimal.xml @@ -0,0 +1,9 @@ + + + + + jenkins + false + + + diff --git a/tests/publishers/fixtures/gitlab-notifier.yaml b/tests/publishers/fixtures/gitlab-notifier-minimal.yaml similarity index 100% rename from tests/publishers/fixtures/gitlab-notifier.yaml rename to tests/publishers/fixtures/gitlab-notifier-minimal.yaml diff --git a/tests/publishers/fixtures/gitlab-notifier.xml b/tests/publishers/fixtures/gitlab-notifier.xml deleted file mode 100644 index 9685dc9f2..000000000 --- a/tests/publishers/fixtures/gitlab-notifier.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - -