Browse Source

Adding publisher support to join-trigger plugin

the join-trigger plugin supports publishers to be triggered on a join.
Only certain publishers work, but this should enable support for it.

Change-Id: I04afc2aedd0c57e9e64c46dbdc7f694d47186bbb
Signed-off-by: Kyle Rockman <kyle.rockman@mac.com>
Kyle Rockman 4 years ago
parent
commit
e043e74267

+ 12
- 1
jenkins_jobs/modules/publishers.py View File

@@ -1966,7 +1966,11 @@ def join_trigger(parser, xml_parent, data):
1966 1966
     """yaml: join-trigger
1967 1967
     Trigger a job after all the immediate downstream jobs have completed
1968 1968
 
1969
+    :arg bool even-if-unstable: if true jobs will trigger even if some
1970
+        downstream jobs are marked as unstable (default false)
1969 1971
     :arg list projects: list of projects to trigger
1972
+    :arg list publishers: list of triggers from publishers module that
1973
+        defines projects that need to be triggered
1970 1974
 
1971 1975
     Example:
1972 1976
 
@@ -1975,10 +1979,17 @@ def join_trigger(parser, xml_parent, data):
1975 1979
     """
1976 1980
     jointrigger = XML.SubElement(xml_parent, 'join.JoinTrigger')
1977 1981
 
1978
-    # Simple Project List
1979 1982
     joinProjectsText = ','.join(data.get('projects', ['']))
1980 1983
     XML.SubElement(jointrigger, 'joinProjects').text = joinProjectsText
1981 1984
 
1985
+    publishers = XML.SubElement(jointrigger, 'joinPublishers')
1986
+    for pub in data.get('publishers', []):
1987
+        for edited_node in create_publishers(parser, pub):
1988
+            publishers.append(edited_node)
1989
+
1990
+    unstable = str(data.get('even-if-unstable', 'false')).lower()
1991
+    XML.SubElement(jointrigger, 'evenIfDownstreamUnstable').text = unstable
1992
+
1982 1993
 
1983 1994
 def jabber(parser, xml_parent, data):
1984 1995
     """yaml: jabber

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

@@ -3,6 +3,29 @@
3 3
   <publishers>
4 4
     <join.JoinTrigger>
5 5
       <joinProjects>project-one,project-two</joinProjects>
6
+      <joinPublishers>
7
+        <hudson.plugins.parameterizedtrigger.BuildTrigger>
8
+          <configs>
9
+            <hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
10
+              <configs>
11
+                <hudson.plugins.parameterizedtrigger.CurrentBuildParameters/>
12
+              </configs>
13
+              <projects>archive</projects>
14
+              <condition>ALWAYS</condition>
15
+              <triggerWithNoParameters>false</triggerWithNoParameters>
16
+            </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
17
+            <hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
18
+              <configs>
19
+                <hudson.plugins.parameterizedtrigger.CurrentBuildParameters/>
20
+              </configs>
21
+              <projects>cleanup</projects>
22
+              <condition>ALWAYS</condition>
23
+              <triggerWithNoParameters>false</triggerWithNoParameters>
24
+            </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
25
+          </configs>
26
+        </hudson.plugins.parameterizedtrigger.BuildTrigger>
27
+      </joinPublishers>
28
+      <evenIfDownstreamUnstable>true</evenIfDownstreamUnstable>
6 29
     </join.JoinTrigger>
7 30
   </publishers>
8 31
 </project>

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

@@ -3,3 +3,10 @@ publishers:
3 3
       projects:
4 4
         - project-one
5 5
         - project-two
6
+      even-if-unstable: true
7
+      publishers:
8
+        - trigger-parameterized-builds:
9
+          - project: archive
10
+            current-parameters: true
11
+          - project: cleanup
12
+            current-parameters: true

Loading…
Cancel
Save