function handlePullRequestEvent()

in ci_tools/codecommit_pr_notifications.js [34:68]


function handlePullRequestEvent(event, callback) {
  // Start a build if this is a notification about a pull request update
  const eventType = event.detail.event;
  if (eventType == "pullRequestCreated" || eventType == "pullRequestSourceBranchUpdated") {
    const pullRequestId = event.detail.pullRequestId;
    // TODO Replace this line with your own logic for how to map CodeCommit repos to CodeBuild projects
    const projectName = defaultCodebuildProject;

    var params = {
      projectName: projectName,
      sourceVersion: event.detail.sourceCommit,
      // We will use the pull request env variables later to post a comment about the build to the PR
      environmentVariablesOverride: [
        {
          name: "CODECOMMIT_PULL_REQUEST_ID",
          value: event.detail.pullRequestId,
          type: "PLAINTEXT"
        },
        {
          name: "CODECOMMIT_PULL_REQUEST_SRC_COMMIT",
          value: event.detail.sourceCommit,
          type: "PLAINTEXT"
        },
        {
          name: "CODECOMMIT_PULL_REQUEST_DST_COMMIT",
          value: event.detail.destinationCommit,
          type: "PLAINTEXT"
        }
      ]
    };
    startBuild(params, callback);
  } else {
    callback("Not a buildable pull request update");
  }
}