CodeBuild git . .git , git .
CI/CD CloudFormation:
GitBranch:
Description: Github branch to be deployed
Type: String
Default: master
Bash, / CI/CD:
readonly git_branch=$(git branch 2>/dev/null | grep "^*" | colrm 1 2)
aws cloudformation create-stack \
--stack-name ${cicd_stack_name} \
--parameters ParameterKey=GitBranch,ParameterValue=${git_branch}
CodeBuild:
CodeBuildProject:
Type: AWS::CodeBuild::Project
Properties:
Environment:
Type: LINUX_CONTAINER
Image: aws/codebuild/java:openjdk-8
EnvironmentVariables:
- Name: GIT_BRANCH
Value: !Ref GitBranch
buildspec.yml:
post_build:
commands:
- echo [PHASE] Entered the post_build phase...
- echo "[DEBUG] Git branch ${GIT_BRANCH}"