1

I am curious if you can control the output "src" folder in AWS CodeBuild.

Specifically, I see this when debugging the build in CodeBuild.

/codebuild/output/src473482839/src/github.....

I would love to be able to set/change/remove the src473482839 part of that path, because I have a feeling it is causing my sbt to recompile my scala source files, although I am using CodeBuilds new localcache to cache my target folders between builds, the compiled class's canonical path change between builds, which is what I suspect is causing the problem

C.N
  • 218
  • 1
  • 9

1 Answers1

3

After some more debugging I have managed to get my 6 minute builds down to 1:30s.

Although you are not able to set or override the CODEBUILD_SRC_DIR I have found a work around in my buildspec.

This is what my buildspec looks like now, with local caching enabled in codebuild.

version: 0.2

phases:
  pre_build:
    commands:
    - mkdir -p /my/build/folder/
    - cp -a ${CODEBUILD_SRC_DIR}/. /my/build/folder
  build:
    commands:
    - cd /my/build/folder
    - sbt compile test

cache:
  paths:
  - '/root/.ivy2/cache/**/*'
  - '/root/.cache/**/*'
  - 'target/**/*'
  - 'any other target folders you may need'

The key change I had to make was copy over the source(cached target directories) in the pre_build phase, and change directory and compile from the new, static directory

I hope this helps someone else down the road until CodeBuild allows a person to set/override the CODEBUILD_SRC_DIR folder

C.N
  • 218
  • 1
  • 9