bug 846104 - self-serve nightly wildcard matching should be stricter - r=catlee
☠☠ backed out by e7baa3e519f6 ☠ ☠
authorGijs Kruitbosch <gijskruitbosch+bugs@gmail.com>
Tue, 14 Jan 2014 12:14:01 -0500
changeset 230 0b68a3d395b36b3c73bf37f381f2a20fbe5b72b9
parent 229 91dbd2a8c9255712f4a20def43a92c43787cd503
child 231 12a41f69831787ae1f8364186a74c6a8d7b2123c
push id185
push usercoop@mozilla.com
push dateTue, 14 Jan 2014 17:14:19 +0000
reviewerscatlee
bugs846104
bug 846104 - self-serve nightly wildcard matching should be stricter - r=catlee
buildapi/scripts/selfserve-agent.py
--- a/buildapi/scripts/selfserve-agent.py
+++ b/buildapi/scripts/selfserve-agent.py
@@ -444,34 +444,37 @@ class BuildAPIAgent:
         cmd = [self.buildbot, 'sendchange', '--master', pb_url, '--branch',
                repo_path, '--revision', revision, '--revlink', revlink,
                '--user', who, '--comments', 'Submitted via self-serve',
                'dummy']
         log.info("Running %s", cmd)
         subprocess.check_call(cmd)
         return {"errors": False, "msg": "Ok"}
 
-    def _create_build_for_revision(self, who, branch, revision, priority, builder_expression, builder_exclusions=None):
+    def _create_build_for_revision(self, who, branch, revision, priority, builder_expressions, builder_exclusions=None):
         if builder_exclusions is None:
             builder_exclusions = ['%l10n nightly']
         now = time.time()
         repo_path = self._get_repo_path(branch)
 
         # Find builders that have been active in the past 2 weeks
         q = """SELECT DISTINCT buildername FROM buildrequests WHERE
-                buildername LIKE :buildername AND
             """
+        for i, bx in enumerate(builder_expressions):
+            q = q + "buildername LIKE :buildername_expression_%i AND " % i
+
         for i, bx in enumerate(builder_exclusions):
             q = q + "buildername NOT LIKE :buildername_exclusion_%i AND " % i
         q = q + """
           submitted_at > :submitted_at"""
         qparams = {
-            'buildername': builder_expression,
             'submitted_at': time.time() - 14 * 24 * 3600,
         }
+        for i, bx in enumerate(builder_expressions):
+            qparams['buildername_expression_%i' % i] = builder_expressions[i]
         for i, bx in enumerate(builder_exclusions):
             qparams['buildername_exclusion_%i' % i] = builder_exclusions[i]
         result = self.db.execute(text(q), qparams)
 
         buildernames = [r[0] for r in result]
         log.debug("buildernames are %s", buildernames)
 
         # Create a sourcestamp
@@ -531,30 +534,30 @@ class BuildAPIAgent:
         revision = message_data['body']['revision']
         priority = message_data['body']['priority']
         log.info("New PGO build by %s of %s %s", who, branch, revision)
         return self._create_build_for_revision(
             who,
             branch,
             revision,
             priority,
-            "%% %s pgo-build" % branch)
+            ["%% %s pgo-build" % branch])
 
     def do_new_nightly_at_revision(self, message_data, message):
         who = message_data['who']
         branch = message_data['body']['branch']
         revision = message_data['body']['revision']
         priority = message_data['body']['priority']
         log.info("New nightly by %s of %s %s", who, branch, revision)
         return self._create_build_for_revision(
             who,
             branch,
             revision,
             priority,
-            '%' + branch + '%nightly',
+            ['%\_' + branch + '\_%nightly', '% ' + branch + ' %nightly%'],
             ['%' + branch + '_v%nightly', '%l10n nightly'])
 
     def do_cancel_revision(self, message_data, message):
         who = message_data['who']
         branch = message_data['body']['branch']
         revision = "%s%%" % message_data['body']['revision'][:12]
         prefixbranch = "%s%%" % branch
         suffixbranch = "%%%s" % branch