CodeBuild
+ BitBucket
+ CodePipeline
https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html
version: 0.2
env:
variables:
key: "value"
parameter-store:
key: "value"
phases:
install:
commands:
- command
finally:
- command
pre_build:
commands:
- command
finally:
- command
build:
commands:
- command
finally:
- command
post_build:
commands:
- command
finally:
- command
artifacts:
files:
- location
discard-paths: yes
base-directory: location
cache:
paths:
- path
Это продолжение :)
https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html
Typically, resources in an VPC are not accessible by AWS CodeBuild. To
enable access, you must provide additional VPC-specific configuration
information as part of your AWS CodeBuild project configuration. This
includes the VPC ID, the VPC subnet IDs, and the VPC security group IDs.
VPC-enabled builds are then able to access resources inside your VPC.
Project:
Type: AWS::CodeBuild::Project
Properties:
Name: !Sub ${Environment}-${Brand}-${Application}
Artifacts:
Type: CODEPIPELINE
BadgeEnabled: False
EncryptionKey: !Ref ArtifactStoreEncryptionKeyArn
Environment:
ComputeType: BUILD_GENERAL1_SMALL
Image: !Ref Image
PrivilegedMode: !Ref PrivilegedMode
Type: LINUX_CONTAINER
ServiceRole: !Ref ProjectRole
Source:
Type: CODEPIPELINE
BuildSpec: !Sub build/${Environment}-${Brand}-${Application}-buildspec.yml
TimeoutInMinutes: 10
VpcConfig:
SecurityGroupIds:
- !Ref ProjectSecurityGroup
Subnets: !Ref PrivateSubnets
VpcId: !Ref VPC
Our project
general-cloudformation-templates
brand-shared-resources
Artifact-store
(brand-shared-resources-dev-artifact-s
tore)
brand-shared-resources-docker
brand-shared-resources-java8
brand-shared-resources-cloudformat
ion-package
application
version: 0.2
phases:
build:
commands:
- aws s3 cp
s3://brand-app-deployment/dependencies/brand-key-store-2017-01-19.jks
code/web/src/main/resources/brand-key-store.jks
- mvn --batch-mode clean verify -Pintegration-test
post_build:
commands:
- cp ./code/web/target/app.jar .
artifacts:
files:
- ./app.jar
- ./infrastructure/**/*
- ./build/**/*
prod-brand-shared-resources-java8-buildspec.yml
version: 0.2
phases:
pre_build:
commands:
- aws cloudformation validate-template --template-body
file://infrastructure/stack/main.yml
- export Bucket=$(echo ${CODEBUILD_SOURCE_VERSION} | cut -d'/' -f1 | cut -d':' -f6)
- export Prefix=$(echo ${CODEBUILD_SOURCE_VERSION} | cut -d'/' -f2)
build:
commands:
- aws cloudformation package --kms-key-id ${CODEBUILD_KMS_KEY_ID} --template
infrastructure/stack/main.yml --s3-bucket "${Bucket}" --s3-prefix "${Prefix}/package"
--output-template-file package.yml
post_build:
commands:
- cp ./infrastructure/*.json .
artifacts:
files:
- ./package.yml
- ./*.json
prod-brand-shared-resources-cloudformation-package-buildspec.yml
DEMO

AWS CodeBuild Demo