How to use the taskcluster.Queue function in taskcluster

To help you get started, we’ve selected a few taskcluster examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozilla / build-tools / buildfarm / release / trigger_action.py View on Github external
parser.add_argument("--partner-build-num", type=int, default=1,
                        help="Specify the partner build number")
    parser.add_argument("--partner-subset", type=str,
                        help="Specify a comma-delimited subset of partners to repack")
    parser.add_argument("--force", action="store_true", default=False,
                        help="Submit action task without asking")
    args = parser.parse_args()
    release_runner_config = yaml.safe_load(args.release_runner_config)
    tc_config = {
        "credentials": {
            "clientId": release_runner_config["taskcluster"].get("client_id"),
            "accessToken": release_runner_config["taskcluster"].get("access_token"),
        },
        "maxRetries": 12,
    }
    queue = taskcluster.Queue(tc_config)

    prev_action_task = get_task(args.action_task_id)
    action_task_input = copy.deepcopy(prev_action_task["extra"]["action"]["context"]["input"])

    decision_task_id = args.decision_task_id
    if decision_task_id:
        params_yaml = get_artifact_text(queue, decision_task_id, 'public/parameters.yml')
    else:
        params_yaml = get_artifact_text(queue, args.action_task_id, 'public/parameters.yml')

    product = args.action_flavor.split('_')[1]
    repo_param_prefix = get_repo_param_prefix(release_runner_config['releases'], product)

    parameters = yaml.safe_load(params_yaml)
    project = parameters["project"]
    revision = parameters['{}head_rev'.format(repo_param_prefix)]
github mozilla / mozilla_ci_tools / mozci / taskcluster / tc.py View on Github external
def get_task(task_id):
    """ Returns task information for given task id.
    """
    queue = taskcluster_client.Queue()
    task = queue.task(task_id)
    LOG.debug("Original task: (Limit 1024 char)")
    LOG.debug(str(json.dumps(task))[:1024])
    return task
github mozilla-mobile / fenix / automation / taskcluster / decision_task.py View on Github external
def raptor(builder, is_staging):
    mozharness_task_id = fetch_mozharness_task_id()
    gecko_revision = taskcluster.Queue({
      'rootUrl': os.environ.get('TASKCLUSTER_PROXY_URL', 'https://taskcluster.net'),
    }).task(mozharness_task_id)['payload']['env']['GECKO_HEAD_REV']

    variant = get_variant('forPerformanceTest', 'geckoNightly')
    build_task = builder.craft_assemble_raptor_task(variant)

    # Signing and Raptor tasks are generated in taskgraph
    return [build_task]
github mozilla / mozmill-ci / lib / tc.py View on Github external
if continuation_token:
                options.update({'continuationToken': continuation_token})

            resp = taskcluster.Queue().listDependentTasks(build_task_id,
                                                          options=options)
            for task in resp['tasks']:
                if task['task'].get('extra', {}).get('suite', {}).get('name') == 'firefox-ui':
                    task_id = task['status']['taskId']
                    break

            continuation_token = resp.get('continuationToken')

            if not continuation_token:
                raise errors.NotFoundException('No tests found which use docker image', image_name)

        task_definition = taskcluster.Queue().task(task_id)

        return task_definition['payload']['image']['taskId']
github mozilla / mozilla_ci_tools / mozci / taskcluster / tc.py View on Github external
def __init__(self, credentials=None, web_auth=False, dry_run=False):
        ''' Initialize the authentication method.'''
        self.dry_run = dry_run

        if dry_run:
            self.queue = taskcluster_client.Queue()

        elif credentials_available():
            self.queue = taskcluster_client.Queue()

        elif credentials:
            self.queue = taskcluster_client.Queue({'credentials': credentials})

        elif web_auth:
            # Your browser will open a new tab asking you to authenticate
            # through TaskCluster and then grant access to this
            self.queue = taskcluster_client.Queue({'credentials': authenticate()})

        else:
            raise TaskClusterError(
                ""
                "Since you're not running in dry run mode, you need to provide "
github mozilla / build-tools / buildfarm / release / releasetasks_graph_gen.py View on Github external
def get_items_from_common_tc_task(common_task_id, tc_config):
    tc_task_items = {}
    queue = Queue(tc_config)
    task = queue.task(common_task_id)
    tc_task_items["version"] = task["extra"]["build_props"]["version"]
    tc_task_items["build_number"] = task["extra"]["build_props"]["build_number"]
    tc_task_items["mozilla_revision"] = task["extra"]["build_props"]["revision"]
    tc_task_items["partials"] = task["extra"]["build_props"]["partials"]
    tc_task_items["mozharness_changeset"] = task["extra"]["build_props"]["mozharness_changeset"]
    tc_task_items["release_eta"] = task["extra"]["build_props"].get("release_eta")
    return tc_task_items
github mozilla / build-tools / buildfarm / release / releasetasks_graph_gen.py View on Github external
def main(release_runner_config, release_config, tc_config, options):

    api_root = release_runner_config['api']['api_root']
    username = release_runner_config['api']['username']
    password = release_runner_config['api']['password']

    queue = Queue(tc_config)
    index = Index(tc_config)

    rr = ReleaseRunner(api_root=api_root, username=username, password=password)
    log.info('Generating task graph')
    kwargs = {
        # release-runner.ini
        "signing_pvt_key": release_config['signing_pvt_key'],
        "public_key": release_config['docker_worker_key'],
        "balrog_username": release_config['balrog_username'],
        "balrog_password": release_config['balrog_password'],
        "beetmover_aws_access_key_id": release_config['beetmover_aws_access_key_id'],
        "beetmover_aws_secret_access_key": release_config['beetmover_aws_secret_access_key'],
        # ship-it items
        "version": release_config["version"],
        "revision": release_config["mozilla_revision"],
        "mozharness_changeset": release_config.get("mozharness_changeset") or release_config["mozilla_revision"],
github mozilla / mozmill-ci / lib / tc.py View on Github external
try:
            logger.debug('Querying Taskcluster for "desktop-test" docker image for "{}"...'.format(
                properties['branch']))
            build_task_id = taskcluster.Index().findTask(build_index)['taskId']
        except taskcluster.exceptions.TaskclusterFailure:
            raise errors.NotFoundException('Required build not found for TC index', build_index)

        task_id = None
        continuation_token = None
        while not task_id:
            options = {'limit': 5}
            if continuation_token:
                options.update({'continuationToken': continuation_token})

            resp = taskcluster.Queue().listDependentTasks(build_task_id,
                                                          options=options)
            for task in resp['tasks']:
                if task['task'].get('extra', {}).get('suite', {}).get('name') == 'firefox-ui':
                    task_id = task['status']['taskId']
                    break

            continuation_token = resp.get('continuationToken')

            if not continuation_token:
                raise errors.NotFoundException('No tests found which use docker image', image_name)

        task_definition = taskcluster.Queue().task(task_id)

        return task_definition['payload']['image']['taskId']
github mozilla / mozilla_ci_tools / mozci / sources / tc.py View on Github external
expiration, creation and deadline values.

    task_id (int)  - ID that identifies a task on Taskcluster
    dry_run (bool) - Default to False. If True, it won't trigger
                     a task.

    returns - 0 for dry_run case, -1 for any failure or the task id (int)
              of a succesful retriggered task.

    http://docs.taskcluster.net/queue/api-docs/#createTask
    """
    one_year = 365
    new_task_id = 0

    try:
        queue = taskcluster_client.Queue()
        task = queue.task(task_id)

        LOG.debug("Original task: (Limit 1024 char)")
        LOG.debug(str(json.dumps(task))[:1024])
        new_task_id = taskcluster_client.slugId()

        artifacts = task['payload'].get('artifacts', {})
        for artifact, definition in artifacts.iteritems():
            definition['expires'] = taskcluster_client.fromNow('%s days' % one_year)

        # The task group will be identified by the ID of the only
        # task in the group
        task['taskGroupId'] = new_task_id
        # https://bugzilla.mozilla.org/show_bug.cgi?id=1190660
        # TC workers create public logs which are 365 days; if the task expiration
        # date is the same or less than that we won't have logs for the task
github mozilla / application-services / automation / taskcluster / decision_task_pull_request.py View on Github external
"path": "/build/application-services/logins-api/android/library/build/outputs/aar/logins-release.aar",
                },
            }
        },
        "provisionerId": "aws-provisioner-v1",
        "metadata": {
            "name": "application-services - FxA client library",
            "description": "Builds the FxA client and the Logins API for Android architectures.",
            "owner": "nalexander@mozilla.com",
            "source": "https://github.com/mozilla/application-services"
        }
    }


if __name__ == "__main__":
    queue = taskcluster.Queue({'baseUrl': 'http://taskcluster/queue/v1'})

    schedule_task(queue, taskcluster.slugId(), create_fxaclient_task())