From 073e7bb5e54d69ee069b15e79b1d1e2d18fc28c0 Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Mon, 1 Jul 2019 12:56:33 +0200 Subject: Add support for GH Custom Notification Context Task: #35637 Story: #2006141 Change-Id: Id4bbc73a709a7cd292072ab66666bd647f0514a6 --- jenkins_jobs/modules/project_multibranch.py | 12 ++++++++++++ tests/multibranch/fixtures/scm_github_full.xml | 4 ++++ tests/multibranch/fixtures/scm_github_full.yaml | 1 + 3 files changed, 17 insertions(+) diff --git a/jenkins_jobs/modules/project_multibranch.py b/jenkins_jobs/modules/project_multibranch.py index a563f24f..1228f0dd 100644 --- a/jenkins_jobs/modules/project_multibranch.py +++ b/jenkins_jobs/modules/project_multibranch.py @@ -796,6 +796,10 @@ def github_scm(xml_parent, data): discovered initially or a change from the previous revision has been detected. (optional) Refer to :func:`~build_strategies `. + :arg str notification-context: Change the default GitHub check notification + context from "continuous-integration/jenkins/SUFFIX" to a custom text, + Requires the :jenkins-wiki:`Github Custom Notification Context SCM + Behaviour `. :arg dict property-strategies: Provides control over how to build a branch (like to disable SCM triggering or to override the pipeline durability) (optional) @@ -980,6 +984,14 @@ def github_scm(xml_parent, data): if data.get('build-strategies', None): build_strategies(xml_parent, data) + if data.get('notification-context', None): + rshf = XML.SubElement(traits, + 'org.jenkinsci.plugins.githubScmTraitNotificationContext.' + 'NotificationContextTrait') + XML.SubElement(rshf, 'contextLabel').text = data.get( + 'notification-context') + XML.SubElement(rshf, 'typeSuffix').text = 'true' + # handle the default git extensions like: # - clean # - shallow-clone diff --git a/tests/multibranch/fixtures/scm_github_full.xml b/tests/multibranch/fixtures/scm_github_full.xml index 208c0abb..2d914b2b 100644 --- a/tests/multibranch/fixtures/scm_github_full.xml +++ b/tests/multibranch/fixtures/scm_github_full.xml @@ -55,6 +55,10 @@ (.*/master|.*/release/.*) + + jenkins.example.com/my_context + true + diff --git a/tests/multibranch/fixtures/scm_github_full.yaml b/tests/multibranch/fixtures/scm_github_full.yaml index 842747b6..42350c67 100644 --- a/tests/multibranch/fixtures/scm_github_full.yaml +++ b/tests/multibranch/fixtures/scm_github_full.yaml @@ -15,6 +15,7 @@ scm: discover-pr-forks-trust: everyone discover-pr-origin: both discover-tags: true + notification-context: 'jenkins.example.com/my_context' property-strategies: all-branches: - suppress-scm-triggering: true -- cgit