How to use the @brigadecore/brigadier/out/job.Job function in @brigadecore/brigadier

To help you get started, we’ve selected a few @brigadecore/brigadier 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 brigadecore / brigade / brigade-worker / src / brigadier.ts View on Github external
currentProject = p;
  events.fire(e, p);
}

/**
 * Job describes a particular job.
 *
 * A Job always has a name and an image. The name is used to reference this
 * job in relation to other jobs in the same event. The image corresponds to a
 * container image that will be executed as part of this job.
 *
 * A Job may also have one or more tasks associated with it. Tasks are run
 * (in order) inside of the image. When no tasks are supplied, the image is
 * executed as-is.
 */
export class Job extends jobImpl.Job {
  jr: JobRunner;

  run(): Promise {
    this.jr = new JobRunner().init(this, currentEvent, currentProject, process.env.BRIGADE_SECRET_KEY_REF == 'true');
    this._podName = this.jr.name;
    return this.jr.run().catch(err => {
      // Wrap the message to give clear context.
      console.error(err);
      let msg = `job ${ this.name }(${this.jr.name}): ${err}`;
      return Promise.reject(new Error(msg));
    });
  }

  logs(): Promise {
    return this.jr.logs();
  }