Bug 1252235 - Make try syntax available to mozharness from TaskCluster through an environment variable. r=armenzg draft
authorChris Manchester <cmanchester@mozilla.com>
Mon, 29 Aug 2016 16:33:24 -0700
changeset 413744 aa6ed39fdaa5bec568fabc562319f3a2ed4f4c47
parent 413613 8a494adbc5cced90a4edf0c98cffde906bf7f3ae
child 531278 26eafa9e58bc734e3d3454847f7de2fad1223ba6
push id29486
push userbmo:cmanchester@mozilla.com
push dateWed, 14 Sep 2016 19:14:08 +0000
reviewersarmenzg
bugs1252235
milestone51.0a1
Bug 1252235 - Make try syntax available to mozharness from TaskCluster through an environment variable. r=armenzg MozReview-Commit-ID: HIVIXPQXnQs
.taskcluster.yml
taskcluster/taskgraph/transforms/tests/make_task_description.py
testing/mozharness/mozharness/mozilla/testing/try_tools.py
--- a/.taskcluster.yml
+++ b/.taskcluster.yml
@@ -99,17 +99,17 @@ tasks:
           - -cx
           - >
               cd /home/worker/checkouts/gecko &&
               ln -s /home/worker/artifacts artifacts &&
               ./mach --log-no-times taskgraph decision
               --pushlog-id='{{pushlog_id}}'
               --pushdate='{{pushdate}}'
               --project='{{project}}'
-              --message='{{comment}}'
+              --message={{#shellquote}}{{{comment}}}{{/shellquote}}
               --owner='{{owner}}'
               --level='{{level}}'
               --base-repository='https://hg.mozilla.org/mozilla-central'
               --head-repository='{{{url}}}'
               --head-ref='{{revision}}'
               --head-rev='{{revision}}'
               --revision-hash='{{revision_hash}}'
 
--- a/taskcluster/taskgraph/transforms/tests/make_task_description.py
+++ b/taskcluster/taskgraph/transforms/tests/make_task_description.py
@@ -168,16 +168,19 @@ def docker_worker_setup(config, test, ta
     }
 
     if mozharness['set-moz-node-path']:
         env['MOZ_NODE_PATH'] = '/usr/local/bin/node'
 
     if 'actions' in mozharness:
         env['MOZHARNESS_ACTIONS'] = ' '.join(mozharness['actions'])
 
+    if config.params['project'] == 'try':
+        env['TRY_COMMIT_MSG'] = config.params['message']
+
     # handle some of the mozharness-specific options
 
     if mozharness['tooltool-downloads']:
         worker['relengapi-proxy'] = True
         worker['caches'].append({
             'type': 'persistent',
             'name': 'tooltool-cache',
             'mount-point': '/home/worker/tooltool-cache',
--- a/testing/mozharness/mozharness/mozilla/testing/try_tools.py
+++ b/testing/mozharness/mozharness/mozilla/testing/try_tools.py
@@ -73,16 +73,18 @@ class TryToolsMixin(TransferMixin):
             'reftest',
         )),
     }
 
     def _extract_try_message(self):
         msg = None
         if "try_message" in self.config and self.config["try_message"]:
             msg = self.config["try_message"]
+        elif 'TRY_COMMIT_MSG' in os.environ:
+            msg = os.environ['TRY_COMMIT_MSG']
         elif self._is_try():
             if self.buildbot_config['sourcestamp']['changes']:
                 msg = self.buildbot_config['sourcestamp']['changes'][-1]['comments']
 
             if msg is None or len(msg) == 1024:
                 # This commit message was potentially truncated or not available in
                 # buildbot_config (e.g. if running in TaskCluster), get the full message
                 # from hg.
@@ -149,17 +151,18 @@ class TryToolsMixin(TransferMixin):
         msg_list = self._extract_try_args(message)
         args, _ = parser.parse_known_args(msg_list)
         return getattr(args, flag, False)
 
     def _is_try(self):
         repo_path = None
         if self.buildbot_config and 'properties' in self.buildbot_config:
             repo_path = self.buildbot_config['properties'].get('branch')
-        return self.config.get('branch', repo_path) == 'try'
+        return (self.config.get('branch', repo_path) == 'try' or
+                'TRY_COMMIT_MSG' in os.environ)
 
     @PostScriptAction('download-and-extract')
     def set_extra_try_arguments(self, action, success=None):
         """Finds a commit message and parses it for extra arguments to pass to the test
         harness command line and test paths used to filter manifests.
 
         Extracting arguments from a commit message taken directly from the try_parser.
         """