summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xjenkins_jobs/modules/publishers.py37
-rw-r--r--tests/publishers/fixtures/postbuildscript-full.xml5
-rw-r--r--tests/publishers/fixtures/postbuildscript-full.yaml5
3 files changed, 46 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
)
diff --git a/tests/publishers/fixtures/postbuildscript-full.xml b/tests/publishers/fixtures/postbuildscript-full.xml
index 60d2ac48..f6a24073 100644
--- a/tests/publishers/fixtures/postbuildscript-full.xml
+++ b/tests/publishers/fixtures/postbuildscript-full.xml
@@ -20,6 +20,7 @@
<string>ABORTED</string>
<string>FAILURE</string>
</results>
+ <executeOn>MATRIX</executeOn>
<role>SLAVE</role>
<filePath>/fakepath/generic-two</filePath>
<scriptType>GENERIC</scriptType>
@@ -29,6 +30,7 @@
<string>SUCCESS</string>
<string>UNSTABLE</string>
</results>
+ <executeOn>AXES</executeOn>
<role>MASTER</role>
<filePath>/fakepath/groovy</filePath>
<scriptType>GROOVY</scriptType>
@@ -50,6 +52,7 @@
<string>SUCCESS</string>
<string>UNSTABLE</string>
</results>
+ <executeOn>MATRIX</executeOn>
<role>MASTER</role>
<content>println &quot;Hello world!&quot;</content>
</org.jenkinsci.plugins.postbuildscript.model.Script>
@@ -71,6 +74,7 @@ println &quot;Multi-line script&quot;
<string>SUCCESS</string>
<string>UNSTABLE</string>
</results>
+ <executeOn>AXES</executeOn>
<role>MASTER</role>
<buildSteps>
<hudson.tasks.Shell>
@@ -84,6 +88,7 @@ println &quot;Multi-line script&quot;
<string>ABORTED</string>
<string>FAILURE</string>
</results>
+ <executeOn>BOTH</executeOn>
<role>SLAVE</role>
<buildSteps>
<hudson.tasks.Shell>
diff --git a/tests/publishers/fixtures/postbuildscript-full.yaml b/tests/publishers/fixtures/postbuildscript-full.yaml
index d583b652..bc1325d3 100644
--- a/tests/publishers/fixtures/postbuildscript-full.yaml
+++ b/tests/publishers/fixtures/postbuildscript-full.yaml
@@ -13,12 +13,14 @@ publishers:
- NOT_BUILT
- ABORTED
- FAILURE
+ execute-on: matrix
groovy-script:
- file-path: '/fakepath/groovy'
role: MASTER
build-on:
- SUCCESS
- UNSTABLE
+ execute-on: axes
- file-path: '/fakepath/groovy-too'
role: SLAVE
build-on:
@@ -30,6 +32,7 @@ publishers:
build-on:
- SUCCESS
- UNSTABLE
+ execute-on: matrix
content: 'println "Hello world!"'
- role: SLAVE
build-on:
@@ -45,6 +48,7 @@ publishers:
build-on:
- SUCCESS
- UNSTABLE
+ execute-on: axes
build-steps:
- shell: 'echo "Hello world!"'
- role: SLAVE
@@ -52,6 +56,7 @@ publishers:
- NOT_BUILT
- ABORTED
- FAILURE
+ execute-on: both
build-steps:
- shell: 'echo "Hello world!"'
- shell: 'echo "Goodbye world!"'