From 93ae6dd1e4cb51a8895f79b895a051d50a391a62 Mon Sep 17 00:00:00 2001
From: Matthieu Baerts <matthieu.baerts@tessares.net>
Date: Tue, 31 Aug 2021 17:52:16 +0200
Subject: [PATCH] junit: add 'Skip publishing checks' param

This new option has been added in JUnit v1.39

  https://github.com/jenkinsci/junit-plugin/releases/tag/junit-1.39

The user can decide not to publish issues to SCM provider platforms.

Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Change-Id: I543dbd5cb355acc5106336afd8953a03245df2fa
---
 jenkins_jobs/modules/publishers.py      | 3 +++
 tests/publishers/fixtures/junit001.xml  | 1 +
 tests/publishers/fixtures/junit002.xml  | 1 +
 tests/publishers/fixtures/junit002.yaml | 1 +
 4 files changed, 6 insertions(+)

diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py
index 90fc2852f..7363cee46 100755
--- a/jenkins_jobs/modules/publishers.py
+++ b/jenkins_jobs/modules/publishers.py
@@ -1578,6 +1578,8 @@ def junit(registry, xml_parent, data):
         health score. (default 1.0)
     :arg bool allow-empty-results: Do not fail the build on empty test results
         (default false)
+    :arg bool skip-publishing-checks: Do not publish issues to SCM provider
+        platforms (default false)
     :arg bool test-stability: Add historical information about test
         results stability (default false).
         Requires the Jenkins :jenkins-plugins:`Test stability Plugin
@@ -1612,6 +1614,7 @@ def junit(registry, xml_parent, data):
         ("keep-long-stdio", "keepLongStdio", True),
         ("health-scale-factor", "healthScaleFactor", "1.0"),
         ("allow-empty-results", "allowEmptyResults", False),
+        ("skip-publishing-checks", "skipPublishingChecks", False),
     ]
     helpers.convert_mapping_to_xml(junitresult, data, mapping, fail_required=True)
 
diff --git a/tests/publishers/fixtures/junit001.xml b/tests/publishers/fixtures/junit001.xml
index fc1db95b1..e4d77bc23 100644
--- a/tests/publishers/fixtures/junit001.xml
+++ b/tests/publishers/fixtures/junit001.xml
@@ -6,6 +6,7 @@
       <keepLongStdio>true</keepLongStdio>
       <healthScaleFactor>1.0</healthScaleFactor>
       <allowEmptyResults>false</allowEmptyResults>
+      <skipPublishingChecks>false</skipPublishingChecks>
       <testDataPublishers/>
     </hudson.tasks.junit.JUnitResultArchiver>
   </publishers>
diff --git a/tests/publishers/fixtures/junit002.xml b/tests/publishers/fixtures/junit002.xml
index f2dd4fc4d..0478fe46f 100644
--- a/tests/publishers/fixtures/junit002.xml
+++ b/tests/publishers/fixtures/junit002.xml
@@ -6,6 +6,7 @@
       <keepLongStdio>false</keepLongStdio>
       <healthScaleFactor>2.0</healthScaleFactor>
       <allowEmptyResults>true</allowEmptyResults>
+      <skipPublishingChecks>true</skipPublishingChecks>
       <testDataPublishers>
         <de.esailors.jenkins.teststability.StabilityTestDataPublisher/>
         <hudson.plugins.claim.ClaimTestDataPublisher/>
diff --git a/tests/publishers/fixtures/junit002.yaml b/tests/publishers/fixtures/junit002.yaml
index 1dac894be..269fdd648 100644
--- a/tests/publishers/fixtures/junit002.yaml
+++ b/tests/publishers/fixtures/junit002.yaml
@@ -4,6 +4,7 @@ publishers:
     keep-long-stdio: false
     health-scale-factor: 2.0
     allow-empty-results: true
+    skip-publishing-checks: true
     test-stability: true
     claim-build: true
     measurement-plots: true