author Dustin J. Mitchell <dustin@mozilla.com>
Tue, 25 Sep 2018 20:18:19 +0000
changeset 451433 5ea6f03f845e49d503f5d0283557f54561c41654
parent 451261 28f92797e661694da8f10e3a9a8fbcfff49c919c
child 451467 d0e13414d6512c9fe84911a0dd730e4fb4a28c27
permissions -rw-r--r--
Bug 1492664 - set TASKCLUSTER_ROOT_URL and TASKCLUSTER_PROXY_URL; r=tomprince,glandium Eventually, workers will provide these variables directly (https://bugzilla.mozilla.org/show_bug.cgi?id=1460015). But for now, this ensures that TASKCLUSTER_ROOT_URL is set everywhere, and TASKCLUSTER_PROXY_URL is set wherever the proxy is active. The setup for the mach commands defaults to https://taskcluster.net for user convenience. When the production instance's URL changes, we can simply change that default. This changes the docker build process propagate TASKCLUSTER_ROOT_URL into the docker images where necessary (using %ARG), specifically to create URLs for debian repo paths.

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from __future__ import absolute_import, print_function, unicode_literals

import os
import logging

GECKO = os.path.realpath(os.path.join(__file__, '..', '..', '..'))

# Maximum number of dependencies a single task can have
# https://docs.taskcluster.net/reference/platform/taskcluster-queue/references/api#createTask
# specifies 100, but we also optionally add the decision task id as a dep in
# taskgraph.create, so let's set this to 99.

# Enable fast task generation for local debugging
# This is normally switched on via the --fast/-F flag to `mach taskgraph`
# Currently this skips toolchain task optimizations and schema validation
fast = False

# Default rootUrl to use for command-line invocations
PRODUCTION_TASKCLUSTER_ROOT_URL = 'https://taskcluster.net'

def set_root_url_env():
    """Ensure that TASKCLUSTER_ROOT_URL is set, defaulting when run outside of a task."""
    logger = logging.getLogger('set_root_url_env')

    if 'TASKCLUSTER_ROOT_URL' not in os.environ:
        if 'TASK_ID' in os.environ:
            raise RuntimeError('TASKCLUSTER_ROOT_URL must be set when running in a task')
            logger.info('Setting TASKCLUSTER_ROOT_URL to default value (Firefox CI production)')
    logger.info('Running in Taskcluster instance {}{}'.format(
        ' with taskcluster-proxy' if 'TASKCLUSTER_PROXY_URL' in os.environ else ''))