I am building CI/CD process using CodeBuild and I'd like to have tests run when pull requet is created (I'm using Bitbucket). As I can see I'm able to set up a trigger when pull requests from branch feature/{xxx} is created but also I have to make CodeBuild to checkout to the branch feature/{xxx}. There is input for Source version but I can't put there anything parameterized. How to do it the right way? Or how to do it at all?
Add a comment
|
1 Answer
If your buildspec is static between branches, then you can do a checkout in the buildspec to switch to files from the commit that initiated the webhook.
Use commands like, e.g.
git checkout $CODEBUILD_WEBHOOK_HEAD_REF
Tip: Use printenv in the buildspec to check for available CodeBuild variables and what suits to get the required commit.
- Environment variables in build environments - https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html