Bug 1305720 - Check for --artifact try syntax regardless of is_automation value; r=armenzg
authorMaja Frydrychowicz <mjzffr@gmail.com>
Fri, 23 Sep 2016 14:36:09 -0400
changeset 315391 8a0d7d0adf236ad9ddca4996d0c8b90dc2140203
parent 315390 a75885a39701e5c29b16da7dd0406691e53e850f
child 315392 8837c195fbc64a1fb44d6ce6160a18dd351004c2
push id30748
push usercbook@mozilla.com
push dateWed, 28 Sep 2016 13:53:19 +0000
treeherdermozilla-central@8c84b7618840 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarmenzg
bugs1305720
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1305720 - Check for --artifact try syntax regardless of is_automation value; r=armenzg Check try message for --artifact even if fx_desktop_build.py is run with --skip-buildbot-actions We can't rely on buildbot config. Add checks to TryToolsMixin._extract_try_message so that it works even if self.buildbot_config is None. MozReview-Commit-ID: 1xErjuOArBe
testing/mozharness/mozharness/mozilla/testing/try_tools.py
testing/mozharness/scripts/fx_desktop_build.py
--- a/testing/mozharness/mozharness/mozilla/testing/try_tools.py
+++ b/testing/mozharness/mozharness/mozilla/testing/try_tools.py
@@ -71,29 +71,30 @@ class TryToolsMixin(TransferMixin):
             'devtools-chrome',
             'mochitest',
             'reftest',
         )),
     }
 
     def _extract_try_message(self):
         msg = None
+        buildbot_config = self.buildbot_config or {}
         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 'sourcestamp' in buildbot_config and buildbot_config['sourcestamp'].get('changes'):
+                msg = buildbot_config['sourcestamp']['changes'][-1].get('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.
-                props = self.buildbot_config['properties']
+                props = buildbot_config.get('properties', {})
                 repo_url = 'https://hg.mozilla.org/%s/'
                 if 'revision' in props and 'repo_path' in props:
                     rev = props['revision']
                     repo_path = props['repo_path']
                 else:
                     # In TaskCluster we have no buildbot props, rely on env vars instead
                     rev = os.environ.get('GECKO_HEAD_REV')
                     repo_path = self.config.get('branch')
@@ -107,20 +108,20 @@ class TryToolsMixin(TransferMixin):
 
                 url = '{}json-pushes?changeset={}&full=1'.format(repo_url, rev)
 
                 pushinfo = self.load_json_from_url(url)
                 for k, v in pushinfo.items():
                     if isinstance(v, dict) and 'changesets' in v:
                         msg = v['changesets'][-1]['desc']
 
-            if not msg and 'try_syntax' in self.buildbot_config['properties']:
+            if not msg and 'try_syntax' in buildbot_config.get('properties', {}):
                 # If we don't find try syntax in the usual place, check for it in an
                 # alternate property available to tools using self-serve.
-                msg = self.buildbot_config['properties']['try_syntax']
+                msg = buildbot_config['properties']['try_syntax']
         if not msg:
             self.warning('Try message not found.')
         return msg
 
     def _extract_try_args(self, msg):
         """ Returns a list of args from a try message, for parsing """
         if not msg:
             return None
--- a/testing/mozharness/scripts/fx_desktop_build.py
+++ b/testing/mozharness/scripts/fx_desktop_build.py
@@ -119,19 +119,19 @@ class FxDesktopBuild(BuildScript, TryToo
                     platform_for_log_url += '-pgo'
                 # postrun.py uses stage_platform buildbot prop as part of the log url
                 self.set_buildbot_property('stage_platform',
                                            platform_for_log_url,
                                            write_to_file=True)
             else:
                 self.fatal("'stage_platform' not determined and is required in your config")
 
-            if self.try_message_has_flag('artifact'):
-                self.info('Artifact build requested in try syntax.')
-                self._update_build_variant(rw_config)
+        if self.try_message_has_flag('artifact'):
+            self.info('Artifact build requested in try syntax.')
+            self._update_build_variant(rw_config)
 
     # helpers
     def _update_build_variant(self, rw_config, variant='artifact'):
         """ Intended for use in _pre_config_lock """
         c = self.config
         variant_cfg_path, _ = BuildOptionParser.find_variant_cfg_path(
             '--custom-build-variant-cfg',
             variant,