Browse Source

Merge "Add trigger-from-child-projects option."

tags/2.0.10
Zuul 1 year ago
parent
commit
97922e4046

+ 6
- 0
jenkins_jobs/modules/publishers.py View File

@@ -507,6 +507,8 @@ def trigger_parameterized_builds(registry, xml_parent, data):
507 507
         if any of the property files are not found in the workspace.
508 508
         Only valid when 'property-file' is specified.
509 509
         (default 'False')
510
+    :arg bool trigger-from-child-projects: Trigger build from child projects.
511
+        Used for matrix projects. (default 'False')
510 512
     :arg bool use-matrix-child-files: Use files in workspaces of child
511 513
         builds (default 'False')
512 514
     :arg str matrix-child-combination-filter: A Groovy expression to filter
@@ -560,6 +562,10 @@ def trigger_parameterized_builds(registry, xml_parent, data):
560 562
 
561 563
         condition = XML.SubElement(tconfig, 'condition')
562 564
         condition.text = project_def.get('condition', 'ALWAYS')
565
+        trigger_from_child_projects = XML.SubElement(
566
+            tconfig, 'triggerFromChildProjects')
567
+        trigger_from_child_projects.text = str(
568
+            project_def.get('trigger-from-child-projects', False)).lower()
563 569
         trigger_with_no_params = XML.SubElement(tconfig,
564 570
                                                 'triggerWithNoParameters')
565 571
         trigger_with_no_params.text = str(

+ 2
- 0
tests/publishers/fixtures/join-trigger001.xml View File

@@ -12,6 +12,7 @@
12 12
               </configs>
13 13
               <projects>archive</projects>
14 14
               <condition>ALWAYS</condition>
15
+              <triggerFromChildProjects>true</triggerFromChildProjects>
15 16
               <triggerWithNoParameters>true</triggerWithNoParameters>
16 17
             </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
17 18
             <hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
@@ -20,6 +21,7 @@
20 21
               </configs>
21 22
               <projects>cleanup</projects>
22 23
               <condition>ALWAYS</condition>
24
+              <triggerFromChildProjects>false</triggerFromChildProjects>
23 25
               <triggerWithNoParameters>false</triggerWithNoParameters>
24 26
             </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
25 27
           </configs>

+ 1
- 0
tests/publishers/fixtures/join-trigger001.yaml View File

@@ -8,6 +8,7 @@ publishers:
8 8
         - trigger-parameterized-builds:
9 9
           - project: archive
10 10
             current-parameters: true
11
+            trigger-from-child-projects: true
11 12
             trigger-with-no-params: true
12 13
           - project: cleanup
13 14
             current-parameters: true

+ 1
- 0
tests/publishers/fixtures/trigger-parameterized-builds001.xml View File

@@ -7,6 +7,7 @@
7 7
           <configs class="java.util.Collections$EmptyList"/>
8 8
           <projects>fixture</projects>
9 9
           <condition>SUCCESS</condition>
10
+          <triggerFromChildProjects>false</triggerFromChildProjects>
10 11
           <triggerWithNoParameters>false</triggerWithNoParameters>
11 12
         </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
12 13
       </configs>

+ 1
- 0
tests/publishers/fixtures/trigger-parameterized-builds002.xml View File

@@ -11,6 +11,7 @@
11 11
           </configs>
12 12
           <projects>fixture</projects>
13 13
           <condition>SUCCESS</condition>
14
+          <triggerFromChildProjects>false</triggerFromChildProjects>
14 15
           <triggerWithNoParameters>false</triggerWithNoParameters>
15 16
         </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
16 17
       </configs>

+ 2
- 0
tests/publishers/fixtures/trigger_parameterized_builds/parameter-override-ordering.xml View File

@@ -16,6 +16,7 @@
16 16
           </configs>
17 17
           <projects>another_job</projects>
18 18
           <condition>ALWAYS</condition>
19
+          <triggerFromChildProjects>false</triggerFromChildProjects>
19 20
           <triggerWithNoParameters>false</triggerWithNoParameters>
20 21
         </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
21 22
         <hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
@@ -31,6 +32,7 @@
31 32
           </configs>
32 33
           <projects>yet_another_job</projects>
33 34
           <condition>ALWAYS</condition>
35
+          <triggerFromChildProjects>false</triggerFromChildProjects>
34 36
           <triggerWithNoParameters>false</triggerWithNoParameters>
35 37
         </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
36 38
       </configs>

+ 6
- 0
tests/publishers/fixtures/trigger_parameterized_builds001.xml View File

@@ -13,6 +13,7 @@ bar=foo
13 13
           </configs>
14 14
           <projects>other_job,foo,bar</projects>
15 15
           <condition>ALWAYS</condition>
16
+          <triggerFromChildProjects>false</triggerFromChildProjects>
16 17
           <triggerWithNoParameters>false</triggerWithNoParameters>
17 18
         </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
18 19
         <hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
@@ -30,6 +31,7 @@ bar=foo
30 31
           </configs>
31 32
           <projects>other_job1, other_job2</projects>
32 33
           <condition>ALWAYS</condition>
34
+          <triggerFromChildProjects>false</triggerFromChildProjects>
33 35
           <triggerWithNoParameters>false</triggerWithNoParameters>
34 36
         </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
35 37
         <hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
@@ -46,6 +48,7 @@ bar=foo
46 48
           </configs>
47 49
           <projects>yet_another_job</projects>
48 50
           <condition>ALWAYS</condition>
51
+          <triggerFromChildProjects>false</triggerFromChildProjects>
49 52
           <triggerWithNoParameters>false</triggerWithNoParameters>
50 53
         </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
51 54
         <hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
@@ -57,6 +60,7 @@ bar=foo
57 60
           </configs>
58 61
           <projects>yet_another_job_2</projects>
59 62
           <condition>ALWAYS</condition>
63
+          <triggerFromChildProjects>false</triggerFromChildProjects>
60 64
           <triggerWithNoParameters>false</triggerWithNoParameters>
61 65
         </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
62 66
         <hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
@@ -68,6 +72,7 @@ bar=foo
68 72
           </configs>
69 73
           <projects>yet_another_job_3</projects>
70 74
           <condition>ALWAYS</condition>
75
+          <triggerFromChildProjects>false</triggerFromChildProjects>
71 76
           <triggerWithNoParameters>false</triggerWithNoParameters>
72 77
         </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
73 78
         <hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
@@ -77,6 +82,7 @@ bar=foo
77 82
           </configs>
78 83
           <projects>test-project-same-node</projects>
79 84
           <condition>ALWAYS</condition>
85
+          <triggerFromChildProjects>false</triggerFromChildProjects>
80 86
           <triggerWithNoParameters>false</triggerWithNoParameters>
81 87
         </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
82 88
       </configs>

+ 3
- 0
tests/publishers/fixtures/trigger_parameterized_builds002.xml View File

@@ -12,6 +12,7 @@
12 12
           </configs>
13 13
           <projects>test-project-all</projects>
14 14
           <condition>ALWAYS</condition>
15
+          <triggerFromChildProjects>false</triggerFromChildProjects>
15 16
           <triggerWithNoParameters>false</triggerWithNoParameters>
16 17
         </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
17 18
         <hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
@@ -23,6 +24,7 @@
23 24
           </configs>
24 25
           <projects>test-project-just-name</projects>
25 26
           <condition>ALWAYS</condition>
27
+          <triggerFromChildProjects>false</triggerFromChildProjects>
26 28
           <triggerWithNoParameters>false</triggerWithNoParameters>
27 29
         </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
28 30
         <hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
@@ -34,6 +36,7 @@
34 36
           </configs>
35 37
           <projects>test-project-just-node</projects>
36 38
           <condition>ALWAYS</condition>
39
+          <triggerFromChildProjects>false</triggerFromChildProjects>
37 40
           <triggerWithNoParameters>false</triggerWithNoParameters>
38 41
         </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
39 42
       </configs>

+ 1
- 0
tests/publishers/fixtures/trigger_parameterized_builds003.xml View File

@@ -31,6 +31,7 @@
31 31
           </configs>
32 32
           <projects>other_job,foo,bar</projects>
33 33
           <condition>ALWAYS</condition>
34
+          <triggerFromChildProjects>false</triggerFromChildProjects>
34 35
           <triggerWithNoParameters>false</triggerWithNoParameters>
35 36
         </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
36 37
       </configs>

+ 1
- 0
tests/publishers/fixtures/trigger_parameterized_builds004.xml View File

@@ -15,6 +15,7 @@
15 15
           </configs>
16 16
           <projects>other_job</projects>
17 17
           <condition>ALWAYS</condition>
18
+          <triggerFromChildProjects>false</triggerFromChildProjects>
18 19
           <triggerWithNoParameters>false</triggerWithNoParameters>
19 20
         </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
20 21
       </configs>

+ 1
- 0
tests/publishers/fixtures/trigger_parameterized_builds005.xml View File

@@ -15,6 +15,7 @@
15 15
           </configs>
16 16
           <projects>other_job</projects>
17 17
           <condition>ALWAYS</condition>
18
+          <triggerFromChildProjects>false</triggerFromChildProjects>
18 19
           <triggerWithNoParameters>false</triggerWithNoParameters>
19 20
         </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
20 21
       </configs>

+ 4
- 0
tests/yamlparser/fixtures/second_order_parameter_interpolation002.xml View File

@@ -22,6 +22,7 @@
22 22
           </configs>
23 23
           <projects/>
24 24
           <condition>ALWAYS</condition>
25
+          <triggerFromChildProjects>false</triggerFromChildProjects>
25 26
           <triggerWithNoParameters>false</triggerWithNoParameters>
26 27
         </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
27 28
       </configs>
@@ -54,6 +55,7 @@
54 55
           </configs>
55 56
           <projects>experimental_p2_bar</projects>
56 57
           <condition>ALWAYS</condition>
58
+          <triggerFromChildProjects>false</triggerFromChildProjects>
57 59
           <triggerWithNoParameters>false</triggerWithNoParameters>
58 60
         </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
59 61
       </configs>
@@ -86,6 +88,7 @@
86 88
           </configs>
87 89
           <projects>production_p1_foo</projects>
88 90
           <condition>ALWAYS</condition>
91
+          <triggerFromChildProjects>false</triggerFromChildProjects>
89 92
           <triggerWithNoParameters>false</triggerWithNoParameters>
90 93
         </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
91 94
       </configs>
@@ -118,6 +121,7 @@
118 121
           </configs>
119 122
           <projects/>
120 123
           <condition>ALWAYS</condition>
124
+          <triggerFromChildProjects>false</triggerFromChildProjects>
121 125
           <triggerWithNoParameters>false</triggerWithNoParameters>
122 126
         </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
123 127
       </configs>

+ 6
- 0
tests/yamlparser/fixtures/trigger_parameterized_builds/parameter-override-ordering-001.xml View File

@@ -33,6 +33,7 @@ print(&quot;Doing something cool with python&quot;)
33 33
           </configs>
34 34
           <projects>default_job</projects>
35 35
           <condition>ALWAYS</condition>
36
+          <triggerFromChildProjects>false</triggerFromChildProjects>
36 37
           <triggerWithNoParameters>false</triggerWithNoParameters>
37 38
         </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
38 39
       </configs>
@@ -52,6 +53,7 @@ print(&quot;Doing something cool with python&quot;)
52 53
           </configs>
53 54
           <projects>first_job</projects>
54 55
           <condition>ALWAYS</condition>
56
+          <triggerFromChildProjects>false</triggerFromChildProjects>
55 57
           <triggerWithNoParameters>false</triggerWithNoParameters>
56 58
         </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
57 59
         <hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
@@ -67,6 +69,7 @@ print(&quot;Doing something cool with python&quot;)
67 69
           </configs>
68 70
           <projects>second_job</projects>
69 71
           <condition>ALWAYS</condition>
72
+          <triggerFromChildProjects>false</triggerFromChildProjects>
70 73
           <triggerWithNoParameters>false</triggerWithNoParameters>
71 74
         </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
72 75
       </configs>
@@ -110,6 +113,7 @@ print(&quot;Doing something cool with python&quot;)
110 113
           </configs>
111 114
           <projects>default_job</projects>
112 115
           <condition>ALWAYS</condition>
116
+          <triggerFromChildProjects>false</triggerFromChildProjects>
113 117
           <triggerWithNoParameters>false</triggerWithNoParameters>
114 118
         </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
115 119
       </configs>
@@ -129,6 +133,7 @@ print(&quot;Doing something cool with python&quot;)
129 133
           </configs>
130 134
           <projects>1.2_first_job</projects>
131 135
           <condition>ALWAYS</condition>
136
+          <triggerFromChildProjects>false</triggerFromChildProjects>
132 137
           <triggerWithNoParameters>false</triggerWithNoParameters>
133 138
         </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
134 139
         <hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
@@ -144,6 +149,7 @@ print(&quot;Doing something cool with python&quot;)
144 149
           </configs>
145 150
           <projects>1.2_second_job</projects>
146 151
           <condition>ALWAYS</condition>
152
+          <triggerFromChildProjects>false</triggerFromChildProjects>
147 153
           <triggerWithNoParameters>false</triggerWithNoParameters>
148 154
         </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
149 155
       </configs>

+ 2
- 0
tests/yamlparser/fixtures/trigger_parameterized_builds/parameter-override-ordering-002.xml View File

@@ -30,6 +30,7 @@
30 30
           </configs>
31 31
           <projects/>
32 32
           <condition>UNSTABLE_OR_BETTER</condition>
33
+          <triggerFromChildProjects>false</triggerFromChildProjects>
33 34
           <triggerWithNoParameters>false</triggerWithNoParameters>
34 35
         </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
35 36
       </configs>
@@ -70,6 +71,7 @@
70 71
           </configs>
71 72
           <projects/>
72 73
           <condition>UNSTABLE_OR_BETTER</condition>
74
+          <triggerFromChildProjects>false</triggerFromChildProjects>
73 75
           <triggerWithNoParameters>false</triggerWithNoParameters>
74 76
         </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
75 77
       </configs>

+ 83
- 0
tests/yamlparser/fixtures/trigger_parameterized_builds/parameter-override-ordering-003.xml View File

@@ -0,0 +1,83 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<matrix-project>
3
+  <executionStrategy class="hudson.matrix.DefaultMatrixExecutionStrategyImpl">
4
+    <runSequentially>false</runSequentially>
5
+  </executionStrategy>
6
+  <combinationFilter/>
7
+  <axes>
8
+    <hudson.matrix.TextAxis>
9
+      <name>foo_bar</name>
10
+      <values>
11
+        <string>foo</string>
12
+        <string>bar</string>
13
+      </values>
14
+    </hudson.matrix.TextAxis>
15
+  </axes>
16
+  <actions/>
17
+  <description>&lt;!-- Managed by Jenkins Job Builder --&gt;</description>
18
+  <keepDependencies>false</keepDependencies>
19
+  <displayName>JJB Test1</displayName>
20
+  <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
21
+  <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
22
+  <concurrentBuild>false</concurrentBuild>
23
+  <canRoam>true</canRoam>
24
+  <properties/>
25
+  <scm class="hudson.scm.NullSCM"/>
26
+  <builders/>
27
+  <publishers>
28
+    <hudson.plugins.parameterizedtrigger.BuildTrigger>
29
+      <configs>
30
+        <hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
31
+          <configs class="java.util.Collections$EmptyList"/>
32
+          <projects>foo</projects>
33
+          <condition>ALWAYS</condition>
34
+          <triggerFromChildProjects>true</triggerFromChildProjects>
35
+          <triggerWithNoParameters>false</triggerWithNoParameters>
36
+        </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
37
+      </configs>
38
+    </hudson.plugins.parameterizedtrigger.BuildTrigger>
39
+  </publishers>
40
+  <buildWrappers/>
41
+</matrix-project>
42
+<BLANKLINE>
43
+<?xml version="1.0" encoding="utf-8"?>
44
+<matrix-project>
45
+  <executionStrategy class="hudson.matrix.DefaultMatrixExecutionStrategyImpl">
46
+    <runSequentially>false</runSequentially>
47
+  </executionStrategy>
48
+  <combinationFilter/>
49
+  <axes>
50
+    <hudson.matrix.TextAxis>
51
+      <name>foo_bar</name>
52
+      <values>
53
+        <string>foo</string>
54
+        <string>bar</string>
55
+      </values>
56
+    </hudson.matrix.TextAxis>
57
+  </axes>
58
+  <actions/>
59
+  <description>&lt;!-- Managed by Jenkins Job Builder --&gt;</description>
60
+  <keepDependencies>false</keepDependencies>
61
+  <displayName>JJB Test2</displayName>
62
+  <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
63
+  <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
64
+  <concurrentBuild>false</concurrentBuild>
65
+  <canRoam>true</canRoam>
66
+  <properties/>
67
+  <scm class="hudson.scm.NullSCM"/>
68
+  <builders/>
69
+  <publishers>
70
+    <hudson.plugins.parameterizedtrigger.BuildTrigger>
71
+      <configs>
72
+        <hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
73
+          <configs class="java.util.Collections$EmptyList"/>
74
+          <projects>foo</projects>
75
+          <condition>ALWAYS</condition>
76
+          <triggerFromChildProjects>false</triggerFromChildProjects>
77
+          <triggerWithNoParameters>false</triggerWithNoParameters>
78
+        </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
79
+      </configs>
80
+    </hudson.plugins.parameterizedtrigger.BuildTrigger>
81
+  </publishers>
82
+  <buildWrappers/>
83
+</matrix-project>

+ 36
- 0
tests/yamlparser/fixtures/trigger_parameterized_builds/parameter-override-ordering-003.yaml View File

@@ -0,0 +1,36 @@
1
+- project:
2
+    name: trigger-from-child
3
+    jobs:
4
+        - 'hydra_{name}_jjb-test1'
5
+        - 'hydra_{name}_jjb-test2'
6
+
7
+- job-template:
8
+    project-type: matrix
9
+    axes:
10
+      - axis:
11
+          type: user-defined
12
+          name: foo_bar
13
+          values:
14
+              - foo
15
+              - bar
16
+    name: 'hydra_{name}_jjb-test1'
17
+    display-name: 'JJB Test1'
18
+    publishers:
19
+        - trigger-parameterized-builds:
20
+            - project: 'foo'
21
+              trigger-from-child-projects: true
22
+
23
+- job-template:
24
+    project-type: matrix
25
+    axes:
26
+      - axis:
27
+          type: user-defined
28
+          name: foo_bar
29
+          values:
30
+              - foo
31
+              - bar
32
+    name: 'hydra_{name}_jjb-test2'
33
+    display-name: 'JJB Test2'
34
+    publishers:
35
+        - trigger-parameterized-builds:
36
+            - project: 'foo'

Loading…
Cancel
Save