summaryrefslogtreecommitdiffstats
path: root/jenkins_jobs
diff options
context:
space:
mode:
authorArtem Nikitin <anikitin@networkoptix.com>2020-03-11 15:09:00 +0300
committerThanh Ha (zxiiro) <zxiiro@gmail.com>2020-03-12 17:04:46 +0000
commit9cff4f295ec8020fa3a3ac15795a344666596770 (patch)
tree3a31b7ca2a95c21df4b65871b7fb80e477341a18 /jenkins_jobs
parentf0fa1a71402a765afd5a675a91f1d3d712ec01d0 (diff)
downloadpython-jenkins-job-builder-9cff4f295ec8020fa3a3ac15795a344666596770.tar.gz
python-jenkins-job-builder-9cff4f295ec8020fa3a3ac15795a344666596770.tar.xz
python-jenkins-job-builder-9cff4f295ec8020fa3a3ac15795a344666596770.zip
Add execute-on parameter for post build steps
executeOn setting is available for PostBuildStep since 2.0 version of the Post Build Script plugin. For previous plugin's version executeOn should be set on the PostBuildScript layer. Change-Id: I6b7c9ccfbd0a2d610499074675835e6b5d96cb17 Task: 39028 Story: 2007411
Diffstat (limited to 'jenkins_jobs')
-rwxr-xr-xjenkins_jobs/modules/publishers.py37
1 files changed, 36 insertions, 1 deletions
diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py
index 6c1de7ce..5567cd7d 100755
--- a/jenkins_jobs/modules/publishers.py
+++ b/jenkins_jobs/modules/publishers.py
@@ -4256,6 +4256,10 @@ def postbuildscript(registry, xml_parent, data):
the scripts. Valid options:
SUCCESS / UNSTABLE / FAILURE / NOT_BUILT / ABORTED
(default 'SUCCESS')
+ * ** execute-on (`str`) - For matrix projects, scripts
+ can be run after each axis is built (`axes`), after
+ all axis of the matrix are built (`matrix`) or after
+ each axis AND the matrix are built (`both`). (default `both`)
:arg list groovy-script: Paths to Groovy scripts
@@ -4266,6 +4270,10 @@ def postbuildscript(registry, xml_parent, data):
the scripts. Valid options:
SUCCESS / UNSTABLE / FAILURE / NOT_BUILT / ABORTED
(default 'SUCCESS')
+ * ** execute-on (`str`) - For matrix projects, scripts
+ can be run after each axis is built (`axes`), after
+ all axis of the matrix are built (`matrix`) or after
+ each axis AND the matrix are built (`both`). (default `both`)
:arg list groovy: Inline Groovy
@@ -4276,6 +4284,10 @@ def postbuildscript(registry, xml_parent, data):
the scripts. Valid options:
SUCCESS / UNSTABLE / FAILURE / NOT_BUILT / ABORTED
(default 'SUCCESS')
+ * ** execute-on (`str`) - For matrix projects, scripts
+ can be run after each axis is built (`axes`), after
+ all axis of the matrix are built (`matrix`) or after
+ each axis AND the matrix are built (`both`). (default `both`)
:arg list builders: Execute any number of supported Jenkins builders.
@@ -4287,6 +4299,10 @@ def postbuildscript(registry, xml_parent, data):
the scripts. Valid options:
SUCCESS / UNSTABLE / FAILURE / NOT_BUILT / ABORTED
(default 'SUCCESS')
+ * ** execute-on (`str`) - For matrix projects, scripts
+ can be run after each axis is built (`axes`), after
+ all axis of the matrix are built (`matrix`) or after
+ each axis AND the matrix are built (`both`). (default `both`)
:arg bool mark-unstable-if-failed: Build will be marked unstable
if job will be successfully completed but publishing script will return
@@ -4300,7 +4316,6 @@ def postbuildscript(registry, xml_parent, data):
:arg bool onfailure: Deprecated, replaced with script-only-if-failed
:arg bool script-only-if-failed: Scripts and builders are run only if the
build failed (default false)
-
:arg str execute-on: For matrix projects, scripts can be run after each
axis is built (`axes`), after all axis of the matrix are built
(`matrix`) or after each axis AND the matrix are built (`both`).
@@ -4355,6 +4370,18 @@ def postbuildscript(registry, xml_parent, data):
if version >= pkg_resources.parse_version("2.0"):
+ def add_execute_on(bs_data, result_xml):
+ valid_values = ("matrix", "axes", "both")
+ execute_on = bs_data.get("execute-on")
+ if not execute_on:
+ return
+ if execute_on not in valid_values:
+ raise JenkinsJobsException(
+ "execute-on must be one of %s, got %s" % valid_values, execute_on
+ )
+ execute_on_xml = XML.SubElement(result_xml, "executeOn")
+ execute_on_xml.text = execute_on.upper()
+
################
# Script Files #
################
@@ -4370,6 +4397,8 @@ def postbuildscript(registry, xml_parent, data):
for result in gs_data.get("build-on", ["SUCCESS"]):
XML.SubElement(results_xml, "string").text = result
+ add_execute_on(gs_data, x)
+
helpers.convert_mapping_to_xml(
x, gs_data, script_mapping, fail_required=True
)
@@ -4382,6 +4411,8 @@ def postbuildscript(registry, xml_parent, data):
for result in gs_data.get("build-on", ["SUCCESS"]):
XML.SubElement(results_xml, "string").text = result
+ add_execute_on(gs_data, x)
+
helpers.convert_mapping_to_xml(
x, gs_data, script_mapping, fail_required=True
)
@@ -4401,6 +4432,8 @@ def postbuildscript(registry, xml_parent, data):
for result in gs_data.get("build-on", ["SUCCESS"]):
XML.SubElement(results_xml, "string").text = result
+ add_execute_on(gs_data, x)
+
helpers.convert_mapping_to_xml(
x, gs_data, groovy_mapping, fail_required=True
)
@@ -4419,6 +4452,8 @@ def postbuildscript(registry, xml_parent, data):
for result in bs_data.get("build-on", ["SUCCESS"]):
XML.SubElement(results_xml, "string").text = result
+ add_execute_on(bs_data, x)
+
helpers.convert_mapping_to_xml(
x, bs_data, builder_mapping, fail_required=True
)