I'm using codecommit, codebuild and codepipeline so that each time I commit on a branch, the associated pipeline build from codecommit in codebuild (and then deployment / invalidation)
I have 3 different scripts in my package.json called build-master, build-test & build-prod, associated to the 3 branches respectively master, test & prod.
# buildspec.yml
phases:
install:
commands:
- yarn --dev
pre_build:
commands:
- aws configure set preview.cloudfront true
- bash -c 'echo "Build started `date` on bucket s3://xx.xxxxxx.$CODEBUILD_SOURCE_VERSION.web"'
build:
commands:
- bash -c 'yarn build-$CODEBUILD_SOURCE_VERSION'
artifacts:
files:
- '**/*'
base-directory: 'dist'
name: xxxx-xxxx.$(date +%Y-%m-%d-%h-%M-%s).$(CODEBUILD_SOURCE_VERSION)
$CODEBUILD_SOURCE_VERSION gives me the arn of the pipeline. I've tried other variables provided by codebuild but to no avail.
I also tried to use bash -c to get the branch from git, but in codebuild I don't have access to the repo.
Is there a way to get the name of the branch with my current config ?