Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
//removalPolicy: cdk.RemovalPolicy.DESTROY, // NOT recommended for production code
});
coffeeShopBucket.grantPut(buildRole);
coffeeShopBucket.grantRead(buildRole);
coffeeShopBucket.grantReadWrite(buildRole);
coffeeShopBucket.grantWrite(buildRole);
new codebuild.Project(this, 'CodeBuildProject', {
role: buildRole,
source: defaultSource,
// Enable Docker AND custom caching
cache: codebuild.Cache.local(codebuild.LocalCacheMode.DOCKER_LAYER, codebuild.LocalCacheMode.CUSTOM),
environment: {
buildImage: codebuild.LinuxBuildImage.AMAZON_LINUX_2,
privileged: true,
},
buildSpec: codebuild.BuildSpec.fromObject({
version: '0.2',
phases: {
install:{
'runtime-versions': {
java: 'corretto8'
}
},
build: {
commands: [
'echo "Build all modules"',
'echo "Run Maven clean install to have all the required jars in local .m2 repository"',
'cd sources/coffeeshop',
'mvn clean install -Dmaven.test.skip=true'
private createProjectConfig(config: BuildStageConfig) {
const allowedComputeTypeSizes = ['SMALL', 'MEDIUM', 'LARGE']
const { build, env, install, postBuild, role } = config
const buildImage = CB.LinuxBuildImage.UBUNTU_14_04_NODEJS_8_11_0
const computeType = allowedComputeTypeSizes.includes(config.computeTypeSize)
? `BUILD_GENERAL1_${config.computeTypeSize}`
: CB.ComputeType.Small
const phases = { build, install, post_build: postBuild }
return {
buildSpec: {
artifacts: config.outputArtifacts,
env,
phases,
version: '0.2',
},
environment: { buildImage, computeType },
environmentVariables: mapEnvironmentVariables(env.variables),
role,
} as CB.ProjectProps
private addBuildStage() {
const placement = { atIndex: 1 }
const buildImage = CB.LinuxBuildImage.UBUNTU_14_04_NODEJS_8_11_0
const environment = { buildImage }
const installCmds = []
const buildCmds = []
const postBuildCmds = []
installCmds.push('npm i -g npm')
installCmds.push('npm ci')
buildCmds.push('npm run build')
postBuildCmds.push('npm run test')
const deployEnv = `BRANCH_NAME=${this.branchName} DEPLOY_MODE=${this.mode}`
postBuildCmds.push(`${deployEnv} NO_PROFILE_CHECK=true npm run deploy`)
const install = { commands: installCmds }
const build = { commands: buildCmds }
const postBuild = { commands: postBuildCmds }
const phases = { build, install, post_build: postBuild }