How to use the taskcluster-client.Queue function in taskcluster-client

To help you get started, we’ve selected a few taskcluster-client 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 taskcluster / mozilla-taskcluster / src / jobs / retrigger.js View on Github external
console.log(`Handling retrigger event ${eventId} for ` +
                `task ${taskId} in project '${project}' (${requester})`);

    let task = await queue.task(taskId);
    let { status } = await queue.status(taskId);
    let run = status.runs[runId];
    let taskGraphId = task.taskGroupId;

    // Ensure when retrigger is sent that we use the right scopes for the job.
    let scopes = projectConfig.scopes(this.config.try, project, false);
    // retriggers need to be able to notify anyone (bug 1308543)
    scopes.push('queue:route:notify.*');

    let newGraphId;
    try {
      let queue = new taskcluster.Queue({
        credentials: this.config.taskcluster.credentials,
        authorizedScopes: scopes
      });

      newGraphId = await this.duplicateTaskInTaskGroup(project, queue, taskId)
    } catch(e) {
      console.log(`Error posting retrigger job for '${project}', ${JSON.stringify(e, null, 2)}`);
      await this.postRetriggerFailureJob(project, revision, revisionHash, task, e);
      return;
    }

    let message = {
      requester,
      taskGroupId: newGraphId
    };
github taskcluster / mozilla-taskcluster / src / jobs / retrigger.js View on Github external
import taskcluster from 'taskcluster-client';
import * as projectConfig from '../project_scopes';
import slugid from 'slugid';
import { duplicate as duplicateTask } from '../taskcluster/duplicate_task';
import traverse from 'traverse';
import Project from 'mozilla-treeherder/project';
import { GraphDuplicator, GroupDuplicator } from '../taskcluster/duplicator';

import RetriggerExchange from '../exchanges/retrigger';
import Base from './base';
import Joi from 'joi';

// We use public only operations on the queue here...
const queue = new taskcluster.Queue();

// Schema for the task.extra.treeherder field.
const SCHEMA = Joi.object().keys({
  // Maps directly to `build_platform`
  build: Joi.object().keys({
    platform: Joi.string().required().
      description('Treeherder platform name'),
    os_name: Joi.string().default('-').
      description('Operating system name for build (linux)'),
    architecture: Joi.string().default('-').
      description('Operating system architecture (x64, etc..)')
  }).required().rename('os', 'os_name'),

  machine: Joi.object().keys({
    platform: Joi.string().required(),
    os_name: Joi.string().default('-'),
github taskcluster / taskcluster / services / treeherder / bin / handlers.js View on Github external
// Create InfluxDB connection for submitting statistics
  var influx = new base.stats.Influx({
    connectionString:   cfg.get('influx:connectionString'),
    maxDelay:           cfg.get('influx:maxDelay'),
    maxPendingPoints:   cfg.get('influx:maxPendingPoints')
  });

  // Start monitoring the process
  base.stats.startProcessUsageReporting({
    drain:      influx,
    component:  cfg.get('treeherder:statsComponent'),
    process:    'handlers'
  });

  // Configure queue and queueEvents
  var queue = new taskcluster.Queue({
    baseUrl:        cfg.get('taskcluster:queueBaseUrl')
  });
  var queueEvents = new taskcluster.QueueEvents({
    exchangePrefix: cfg.get('taskcluster:queueExchangePrefix')
  });

  // Load Project objects
  var projects = [];
  _.forIn(JSON.parse(cfg.get('treeherder:projects')), function(project, name) {
    projects.push(new Project(name, {
      consumerKey:          project.consumer_key,
      consumerSecret:       project.consumer_secret,
      baseUrl:              cfg.get('treeherder:baseUrl')
    }));
  });
github nss-dev / nss / automation / taskcluster / graph / src / queue.js View on Github external
import {clone} from "merge";
import merge from "./merge";
import slugid from "slugid";
import taskcluster from "taskcluster-client";
import * as image_builder from "./image_builder";

let maps = [];
let filters = [];

let tasks = new Map();
let tags = new Map();
let image_tasks = new Map();
let parameters = {};

let queue = new taskcluster.Queue({
  rootUrl: process.env.TASKCLUSTER_PROXY_URL,
});

function fromNow(hours) {
  let d = new Date();
  d.setHours(d.getHours() + (hours|0));
  return d.toJSON();
}

function parseRoutes(routes) {
  let rv = [
    `tc-treeherder.v2.${process.env.TC_PROJECT}.${process.env.NSS_HEAD_REVISION}.${process.env.NSS_PUSHLOG_ID}`,
    ...routes
  ];

  // Notify about failures (except on try).
github taskcluster / mozilla-taskcluster / src / treeherder / job_handler.js View on Github external
constructor(config, listener) {
    this.config = config;
    this.queue = new Queue();
    this.scheduler = new Scheduler();

    this.prefix = config.treeherderTaskcluster.routePrefix;
    this.listener = listener;

    // Treeherder project instances used for posting job details to treeherder
    this.projects = {}

    listener.on('message', (message) => {
      return this.handleTaskEvent(message);
    });

    // Pending pushes per repository...
    this._pendingPushes = {
      /**
      example: {
github taskcluster / taskcluster / services / index / bin / handlers.js View on Github external
credentials:      cfg.get('taskcluster:credentials'),
    authBaseUrl:      cfg.get('taskcluster:authBaseUrl')
  });

  // Create a validator
  var validator = null;
  var validatorCreated = base.validator({
    folder:           path.join(__dirname, '..', 'schemas'),
    constants:        require('../schemas/constants'),
    schemaPrefix:     'index/v1/'
  }).then(function(validator_) {
    validator = validator_;
  });

  // Configure queue and queueEvents
  var queue = new taskcluster.Queue({
    baseUrl:        cfg.get('taskcluster:queueBaseUrl'),
    credentials:    cfg.get('taskcluster:credentials')
  });
  var queueEvents = new taskcluster.QueueEvents({
    exchangePrefix: cfg.get('taskcluster:queueExchangePrefix')
  });

  // When: validator is created, proceed
  return validatorCreated.then(function() {
    // Create event handlers
    var handlers = new Handlers({
      IndexedTask:        IndexedTask,
      Namespace:          Namespace,
      queue:              queue,
      queueEvents:        queueEvents,
      credentials:        cfg.get('pulse'),
github taskcluster / mozilla-taskcluster / src / treeherder / handler.js View on Github external
constructor(config, listener) {
    let credentials = JSON.parse(config.treeherder.credentials);

    this.queue = new Queue();
    this.prefix = config.treeherderTaskcluster.routePrefix;
    this.listener = listener;

    this.projects = Object.keys(credentials).reduce((result, key) => {
      let cred = credentials[key];
      result[key] = new Project(key, {
        consumerKey: cred.consumer_key,
        consumerSecret: cred.consumer_secret,
        baseUrl: config.treeherder.apiUrl
      });
      return result;
    }, {});

    listener.on('message', (message) => {
      return this.handle(message);
    });
github sergey-cheperis / nss-nspr-windows / nss / automation / taskcluster / graph / src / image_builder.js View on Github external
async function taskHasImageArtifact(taskId) {
  let queue = new taskcluster.Queue();
  let {artifacts} = await queue.listLatestArtifacts(taskId);
  return artifacts.some(artifact => artifact.name == "public/image.tar");
}
github taskcluster / taskcluster / services / worker-manager / src / main.js View on Github external
    setup: ({cfg}) => new taskcluster.Queue(cfg.taskcluster),
  },