How to use the taskcluster-client.fromEnvVars 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 / taskcluster / infrastructure / tooling / src / smoketest / checks / createClient.js View on Github external
run: async () => {
    const auth = new taskcluster.Auth(taskcluster.fromEnvVars());
    const randomId = taskcluster.slugid();

    let clientId = `project/taskcluster/smoketest/${randomId}`;
    const payload = {
      "expires": taskcluster.fromNowJSON('1 hour'),
      "description": `Create a client and use it ${clientId}`,
      "scopes": [`auth:reset-access-token:project/taskcluster/smoketest/${randomId}`],
    };
    const created = await auth.createClient(clientId, payload);

    // try using that new client
    const accessToken = created.accessToken;
    const auth2 = new taskcluster.Auth({
      rootUrl: process.env.TASKCLUSTER_ROOT_URL,
      credentials: {clientId, accessToken},
    });
github taskcluster / taskcluster / infrastructure / tooling / src / smoketest / checks / role.js View on Github external
run: async () => {
    const auth = new taskcluster.Auth(taskcluster.fromEnvVars());
    const randomId = taskcluster.slugid();
    const roleId = `project:taskcluster:smoketest:${randomId}:*`;

    const payload = {
      description: 'smoketest for creating a role and expanding it',
      scopes: ['project:taskcluster:smoketest:<..>/*'],
    };
    await auth.createRole(roleId, payload);

    const expandPayload = {
      scopes: [`assume:project:taskcluster:smoketest:${randomId}:abc`],
    };
    const expandedRole = await auth.expandScopes(expandPayload);

    const expectedScopes = {
      scopes:
github taskcluster / taskcluster / infrastructure / tooling / src / smoketest / checks / builtin.js View on Github external
let task = {
        provisionerId: 'built-in',
        workerType: taskType,
        created: (new Date()).toJSON(),
        deadline: taskcluster.fromNowJSON('2 minutes'),
        metadata: {
          name: 'Smoketest built-in/' + taskType,
          description: 'built-in/' + taskType + ' task created during smoketest',
          owner: 'smoketest@taskcluster.net',
          source: 'https://taskcluster.net',
        },
        payload: {},
      };
      let taskId = taskcluster.slugid();
      utils.status({message: 'built-in/' + taskType + ' taskId: ' + taskId});
      let queue = new taskcluster.Queue(taskcluster.fromEnvVars());
      await queue.createTask(taskId, task);
      let pollForStatusStart = new Date();
      while((new Date() - pollForStatusStart) < 120000){
        let status = await queue.status(taskId);
        if (status.status.state === 'pending' || status.status.state === 'running'){
          utils.status({
            message: 'Polling built-in/' + taskType + ' task. Current status: ' + status.status.state,
          });
          await new Promise(resolve => setTimeout(resolve, 1000));
        } else if (status.status.state === successCondition) {
          return;
        } else {
          throw new Error('Task finished with status ' + status.status.state);
        }
      }
      throw new Error('Deadline exceeded');
github taskcluster / taskcluster / infrastructure / tooling / src / smoketest / checks / dependencies.js View on Github external
run: async (requirements, utils) => {
    let taskCount = 3;
    let taskIds = [];
    let queue = new taskcluster.Queue(taskcluster.fromEnvVars());
    for (let i = 0; i < taskCount; i++){
      let task = {
        provisionerId: 'built-in',
        workerType: 'succeed',
        created: (new Date()).toJSON(),
        deadline: taskcluster.fromNowJSON('2 minutes'),
        metadata: {
          name: 'Smoketest dependencies task Nr' + (taskCount - i),
          description: 'built-in/succeed task created during dependency smoketest',
          owner: 'smoketest@taskcluster.net',
          source: 'https://taskcluster.net',
        },
        payload: {},
      };
      task.dependencies = [...taskIds];
      taskIds.push(taskcluster.slugid());
github nss-dev / nss / automation / taskcluster / graph / src / image_builder.js View on Github external
async function taskHasImageArtifact(taskId) {
  let queue = new taskcluster.Queue(taskcluster.fromEnvVars());
  let {artifacts} = await queue.listLatestArtifacts(taskId);
  return artifacts.some(artifact => artifact.name == "public/image.tar");
}