summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Fernandez Calvo <kuisathaverat@yahoo.com>2019-07-01 12:56:33 +0200
committerThanh Ha <zxiiro@gmail.com>2019-07-02 12:25:34 -0400
commit073e7bb5e54d69ee069b15e79b1d1e2d18fc28c0 (patch)
tree0f82801e3156d8238d190e26b1f7586a8024a8bd
parent5d15fe76314976f54572f35292de4a8b85c778e9 (diff)
downloadpython-jenkins-job-builder-073e7bb5e54d69ee069b15e79b1d1e2d18fc28c0.tar.gz
python-jenkins-job-builder-073e7bb5e54d69ee069b15e79b1d1e2d18fc28c0.tar.xz
python-jenkins-job-builder-073e7bb5e54d69ee069b15e79b1d1e2d18fc28c0.zip
Add support for GH Custom Notification Context
Task: #35637 Story: #2006141 Change-Id: Id4bbc73a709a7cd292072ab66666bd647f0514a6
-rw-r--r--jenkins_jobs/modules/project_multibranch.py12
-rw-r--r--tests/multibranch/fixtures/scm_github_full.xml4
-rw-r--r--tests/multibranch/fixtures/scm_github_full.yaml1
3 files changed, 17 insertions, 0 deletions
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 <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 <Github+Custom+Notification+Context+SCM+Behaviour+Plugin>`.
: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 @@
<jenkins.scm.impl.trait.RegexSCMHeadFilterTrait>
<regex>(.*/master|.*/release/.*)</regex>
</jenkins.scm.impl.trait.RegexSCMHeadFilterTrait>
+ <org.jenkinsci.plugins.githubScmTraitNotificationContext.NotificationContextTrait>
+ <contextLabel>jenkins.example.com/my_context</contextLabel>
+ <typeSuffix>true</typeSuffix>
+ </org.jenkinsci.plugins.githubScmTraitNotificationContext.NotificationContextTrait>
<jenkins.plugins.git.traits.CleanAfterCheckoutTrait>
<extension class="hudson.plugins.git.extensions.impl.CleanCheckout"/>
</jenkins.plugins.git.traits.CleanAfterCheckoutTrait>
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