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
--- 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,