- Newest
- Most votes
- Most comments
Triggers for codecommit are created/controlled through cloudwatch events. The source for the event can be specific target branch on a Pull Request.
Example - sorry about identing
{
"source": [
"aws.codecommit"
],
"detail-type": [
"CodeCommit Pull Request State Change"
],
"resources": [
"arn:aws:codecommit:us-west-2:80398EXAMPLE:MyTestRepo"
],
"detail": {
"event": [
"pullRequestCreated",
"pullRequestStatusChanged"
],
"destinationReference": [
"refs/heads/main"
],
"pullRequestStatus": [
"Open"
]
}
}
You can natively trigger codepipeline but if you wanted to trigger gitlab you would need to set the cloudwatch event to target a lambda which made the appropriate api call (and credentials) to trigger your gitlab pipeline
Hi Zale,
Please check in cloudwatch events-> rules or eventbridge rules ( both point to the same info ) . Here should be a rule that looks similar like this .
{
"source": [
"aws.codecommit"
],
"detail-type": [
"CodeCommit Repository State Change"
],
"resources": [
"arn:aws:codecommit:us-west-2:123456789012:CodeCommit"
],
"detail": {
"event": [
"referenceCreated",
"referenceUpdated"
],
"referenceType": [
"branch"
],
"referenceName": [
"main"
]
}
}
change the referenceName to the branch you want to use to trigger the codepipeline. If you want to filter not by "feature" , more on a feature pattern like "feature-123" , "feature-124" then try to use filtering on event patterns. Please check this link : https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns-content-based-filtering.html
Please write back if you need more info or if this was helpful.
Relevant content
- asked 2 years ago
- asked 8 months ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
Hi Peter , thanks for your answer! I tried but it’s still running pipeline from the destination branch. Maybe my question was unclear. Let me explain : My branch is develop. I make some changes in another branch ( feature) and want to merge feature and develop. What I want is the pipeline to run feature and not develop. So when I open a pull request in codecommit it will run automatically the source branch feature. I tried the code you gave me but it’s running the code from develop branch.