constructor()

in lib/pipeline.ts [216:280]


  constructor(parent: Construct, name: string, props: PipelineProps) {
    super(parent, name);

    this.concurrency = props.concurrency;
    this.repo = props.repo;
    this.dryRun = !!props.dryRun;

    this.pipeline = new cpipeline.Pipeline(this, 'BuildPipeline', {
      pipelineName: props.pipelineName,
      restartExecutionOnUpdate: props.restartExecutionOnUpdate === undefined ? true : props.restartExecutionOnUpdate,
    });

    this.branch = props.branch || 'master';
    this.sourceArtifact = props.repo.createSourceStage(this.pipeline, this.branch);

    this.buildEnvironment = createBuildEnvironment(props);
    this.buildSpec = props.buildSpec;

    let buildProjectName = props.buildProjectName;
    if (buildProjectName === undefined && props.pipelineName !== undefined) {
      buildProjectName = `${props.pipelineName}-Build`;
    }
    this.buildProject = new cbuild.PipelineProject(this, 'BuildProject', {
      projectName: buildProjectName,
      environment: this.buildEnvironment,
      buildSpec: this.buildSpec,
      timeout: props.buildTimeout ?? Duration.hours(8),
    });

    this.buildRole = this.buildProject.role;

    const buildStage = this.getOrCreateStage('Build');
    const buildOutput = new cpipeline.Artifact();
    buildStage.addAction(new cpipeline_actions.CodeBuildAction({
      actionName: 'Build',
      project: this.buildProject,
      input: this.sourceArtifact,
      outputs: [buildOutput],
    }));
    this.buildOutput = buildOutput;

    if (props.notificationEmail) {
      this.notify = new sns.Topic(this, 'NotificationsTopic');
      this.notify.addSubscription(new sns_subs.EmailSubscription(props.notificationEmail));
    }

    // add a failure alarm for the entire pipeline.
    this.failureAlarm = this.addFailureAlarm(props.title);

    // emit an SNS notification every time build fails.
    this.addBuildFailureNotification(this.buildProject, `${props.title} build failed`);

    // Also emit to Chime webhooks if configured
    if (props.chimeFailureWebhooks) {
      new ChimeNotifier(this, 'ChimeNotifier', {
        pipeline: this.pipeline,
        message: props.chimeMessage,
        webhookUrls: props.chimeFailureWebhooks,
      });
    }

    if (props.autoBuild) {
      this.autoBuildProject = this.autoBuild(props.autoBuildOptions).project;
    }
  }