Commits

Matt Oswald committed 8ec2463

added support for regex in branches

Comments (0)

Files changed (1)

 import os
 sys.path.append(os.path.dirname(__file__))
 
+import re
+
 from jenkins import Jenkins
 from configuration import Configuration
 
 
     ui.debug("checking jobs" + "\n")
     ui.debug("branch: " + ctx.branch() + "\n")
-    if jobs.has_key(ctx.branch()):
-        ui.debug("jobs for branch found" + "\n")
-        branchjobs = jobs[ctx.branch()]
 
-        for job in branchjobs:
-            if job.subdir == '':
-                ui.debug("added job " + job.name + "\n")
-                result.add(job)
-            else:
-                ui.debug("checking files for path: " + job.subdir + "\n")
-                for file in ctx.files():
-                    ui.debug("current file: " + file + "\n")
-                    if file.startswith(job.subdir):
-                        ui.debug("added job" + job.name + "\n")
-                        result.add(job)
-                        break
+    for key in jobs.keys():
+        regex = re.compile(key)
+        if regex.match(ctx.branch()):
+            ui.debug("jobs for branch found" + "\n")
+            branchjobs = jobs[key]
+
+            for job in branchjobs:
+                if job.subdir == '':
+                    ui.debug("added job " + job.name + "\n")
+                    result.add(job)
+                else:
+                    ui.debug("checking files for path: " + job.subdir + "\n")
+                    for file in ctx.files():
+                        ui.debug("current file: " + file + "\n")
+                        if file.startswith(job.subdir):
+                            ui.debug("added job" + job.name + "\n")
+                            result.add(job)
+                            break
 
     return result