Miguel Angel Acevedo
Miguel Angel Acevedo

Reputation: 299

AWS Codebuild not starting when pushing commit and tag

I followed this tutorial https://ruddra.com/aws-codebuild-use-git-tags/ to make my codebuild in aws only trigger when tag is pushed to my bitbucket project, and it works if I'm ONLY pusing tags.

It works here:

# make some code changes

git add .
git commit -m "changes"
git push origin HEAD # OK: codebuild not trigered as expected

git tag v1
git push origin HEAD --tags # SUCCESS: codebuild is triggered

but if I tag with a commit:

# make some code changes

git add .
git commit -m "changes"
git tag v1
git push origin HEAD --tags # UNSUCCESS: codebuild is NOT triggered

it has to do with the expression: ^refs/tags/.* ?

Bitbucket payload

I was trying to figure out by checking the bitbucket payload, it seems when the tag hash doesn't match the current $CODEBUILD_SOURCE_VERSION, it won't check the tag (My guess so far)

Working payload (push tag)

push.changes[0].type: "tag"
push.changes[0].target.hash: "6f08xxx", <== $CODEBUILD_SOURCE_VERSION

Non Working payload (push commmit + tag)

push.changes[0].type: "branch"
push.changes[0].target.hash: "25b7xxx", <== $CODEBUILD_SOURCE_VERSION

push.changes[0].type: "tag"
push.changes[0].target.hash: "6f08xxx",

you may noticed the 6f08xxx repeated, it's because during my testing I tried the non-working steps first and then I just tag and push, that's why I'm guessing the hash has to do with the checking of the tags on codebuild

Any help to solve or debug this would be appretiated.

Thanks for your time in advance

Upvotes: 0

Views: 1987

Answers (1)

Miguel Angel Acevedo
Miguel Angel Acevedo

Reputation: 299

I found the issue, the problem is the git push origin HEAD --tags, I should not push the HEAD but the tag like this

git push origin v1

then it works like a charm.

Upvotes: 0

Related Questions