0
votes

I am using bitbucket as source control and codepipeline as CI/CD tool. I created the codepipeline's source action from CDK as below code:

new actions.BitBucketSourceAction({
          actionName: 'SourceAction',
          owner: bitbucketOwner,
          connectionArn: codeStar,
          branch: branchName,
          output: this.sourceOutput,
          repo: bitbucketName,
        }),

after finish deploying codepipeline, it is triggered automatically when a commit pushed to bitbucket branch. How can I stop it doing that? I'd like to make a commit to trigger a codebuild project from where it triggers codepipeline.

In codepipeline source action console, I can see this checkbox:

enter image description here

but how can I set this configuration in CDK?

1

1 Answers

0
votes

This has become possible in version 1.95.0. There is now triggerOnPush parameter available in BitBucketSourceActionProps. Add it to your BitBucketSourceAction with value false

new actions.BitBucketSourceAction({
      actionName: 'SourceAction',
      owner: bitbucketOwner,
      connectionArn: codeStar,
      branch: branchName,
      output: this.sourceOutput,
      repo: bitbucketName,
      triggerOnPush: false
    }),

Fun fact: if someone needs Github version 2 source actions, BitBucketSourceAction works just fine also for github. It is just unfortunately named as admitted by CDK contributors here and here. To avoid as much confussion as possible for my fellow developers I'm importing it using alias

import { BitBucketSourceAction as GitHubSourceAction } from "@aws-cdk/aws-codepipeline-actions";

new GitHubSourceAction({
      actionName: 'SourceAction',
      owner: githubOwner,
      connectionArn: codeStar,
      branch: branchName,
      output: this.sourceOutput,
      repo: githubRepositoryName,
      triggerOnPush: false
    }),