I am trying to use multiple CodeCommit sources in my CodePipeline build. I defined a secondary source pointing to a project in CodeCommit in CodeBuild and assigned it "sec_proj" identifier. In my main project I have a Gradle build which has the following code
copy {
from System.getProperty("CODEBUILD_SRC_DIR_sec_proj", CODEBUILD_SRC_DIR_sec_proj)
into "$buildDir/sec_proj"
}
When I define CODEBUILD_SRC_DIR_sec_proj
in my local environment everything runs as expected, files from the 2nd project are copied and build completes. However when I attempt to run it in my pipeline I get the following error:
17:50:26.092 [ERROR]
[org.gradle.internal.buildevents.BuildExceptionReporter] Caused by:
groovy.lang.MissingPropertyException: Could not get unknown property
'CODEBUILD_SRC_DIR_sec_proj' for object of type
org.gradle.api.internal.file.copy.CopySpecWrapper_Decorated.
So obviously my gradle process does not have this variable available.
I tried to force it using the following syntax in my buildspec.yml
phases:
build:
commands:
- ./gradlew -i -d -S build -DCODEBUILD_SRC_DIR_sec_proj=$CODEBUILD_SRC_DIR_sec_proj
And it failed with same message. And since according to the documentation
Your primary source is defined under the source attribute. All other sources are called secondary sources and appear under secondarySources. All secondary sources are installed in their own directory. This directory is stored in the built-in environment variable CODEBUILD_SRC_DIR_sourceIdentifer.
it looks like I'm missing something?