How to Trigger AWS code Pipeline on any branch with specific Tag

0

I have my AWS Codebuild config in a way when pushing changes to any branch with tag ^refs/tags/pak/* it will trigger the build, Enter image description here

Now I want to create a code pipeline in the same way but in the code pipeline, a branch name is required, I want to trigger pipeline with tags

asked 7 months ago1135 views
3 Answers
0

If you are using CodeCommit as Repo you can use an EventBridge trigger to invoke your pipeline:

  1. Create Eventbridge rule - here is an example rule:
{
  "source": ["aws.codecommit"],
  "detail-type": ["CodeCommit Repository State Change"],
  "resources": ["arn:aws:codecommit:{{region}}:{{account_id}}:Test-Repo"],
  "detail": {
    "event": ["referenceCreated", "referenceUpdated"],
    "repositoryName": ["Test-Repo"],
    "referenceType": ["tag"],
    "referenceName": [{
      "prefix": "dev"
    }]
  }
}
  1. Configuring the CodePipeline target by providing the ARN of the created pipeline.

Here are the docs for Eventbrdige: https://docs.aws.amazon.com/eventbridge/

profile picture
David
answered 7 months ago
0

If you are using GitHub you may use a github action for the specific tag and inside the action you can use the AWS CodePipeline Trigger

profile picture
David
answered 7 months ago
  • By doing so we can trigger the pipeline but what about the branch name it is asking at the beginning of the creation of the pipeline would not it pull changes from that branch?

0

You can just use any branch name and remove that afterwards eg.:

Find out the name of the webhook: aws codepipeline list-webhooks De-register: aws codepipeline deregister-webhook-with-third-party --webhook-name <webhook-name> Delete: aws codepipeline delete-webhook --name <webhook-name>

profile picture
David
answered 7 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions