Roopesh Kumar
Roopesh Kumar

Reputation: 41

triggering the code pipeline only if user creates a tag in the code repo

Is it possible to configure the cloud watch event pattern for invoking the codepipeline when user creates a tag in the code commit repository? Or there is any way for restricting user to not run the pipeline on every commit?

Upvotes: 3

Views: 6019

Answers (2)

mumbo_s5
mumbo_s5

Reputation: 171

Answering a rather old question, you can create a CloudWatch event to trigger the CodePipeline only on a tag creation. Make sure to use CloudWatch event as the "Change detection options" and delete/disable any events pre/auto configured to trigger on commits.

You can use a rule similar to following, Described here

{
  "source": [
    "aws.codecommit"
  ],
  "detail-type": [
    "CodeCommit Repository State Change"
  ],
  "resources": [
    "<Your repository ARN>"
  ],
  "detail": {
    "event": [
      "referenceCreated"
    ],
    "repositoryName": [
      "<Your repository name>"
    ],
    "referenceType": [
      "tag"
    ]
  }
}

Also, this document describes all available CloudWatch event types.

Upvotes: 7

joakim
joakim

Reputation: 4081

I don't think this is currently supported by CodePipeline.

What I did to get the same effect is let the pipeline run as usual and in the build step (I was using CodeBuild in this instance but it applies to any CI tool e.g. Jenkins) I immediately check if the commit is tagged using git commands and abort the build if it isn't.

It's obviously less than ideal but it does get the job done.

Upvotes: 1

Related Questions