Bug 1355105 - Cron.yml requires a 'when' for all projects even if not specified in 'run-on-projects'. r=dustin draft
authorJustin Wood <Callek@gmail.com>
Mon, 10 Apr 2017 11:23:49 -0400
changeset 559864 b7481a705f8b0e8d2afde295bc37c8975cb61787
parent 559608 731639fccc709a4dd95fed7e9dda88efb2227906
child 623531 cd8e624b31eb76c45bf935078e74fe5fab05174f
push id53235
push userCallek@gmail.com
push dateMon, 10 Apr 2017 17:59:46 +0000
reviewersdustin
bugs1355105
milestone55.0a1
Bug 1355105 - Cron.yml requires a 'when' for all projects even if not specified in 'run-on-projects'. r=dustin MozReview-Commit-ID: CIKcRtGfvIM
taskcluster/taskgraph/cron/__init__.py
--- a/taskcluster/taskgraph/cron/__init__.py
+++ b/taskcluster/taskgraph/cron/__init__.py
@@ -38,27 +38,28 @@ logger = logging.getLogger(__name__)
 
 def load_jobs(params):
     with open(os.path.join(GECKO, '.cron.yml'), 'rb') as f:
         cron_yml = yaml.load(f)
     schema.validate(cron_yml)
 
     # resolve keyed_by fields in each job
     jobs = cron_yml['jobs']
-    for job in jobs:
-        resolve_keyed_by(job, 'when', 'Cron job ' + job['name'],
-                         project=params['project'])
 
     return {j['name']: j for j in jobs}
 
 
 def should_run(job, params):
     run_on_projects = job.get('run-on-projects', ['all'])
     if not match_run_on_projects(params['project'], run_on_projects):
         return False
+    # Resolve when key here, so we don't require it before we know that we
+    # actually want to run on this branch.
+    resolve_keyed_by(job, 'when', 'Cron job ' + job['name'],
+                     project=params['project'])
     if not any(match_utc(params, hour=sched.get('hour'), minute=sched.get('minute'))
                for sched in job.get('when', [])):
         return False
     return True
 
 
 def run_job(job_name, job, params):
     params['job_name'] = job_name