Skip to content

Commit 0ae568c

Browse files
authored
Merge pull request #162 from awszhen/codebuild
Add option for mounting source directory to the customer build contai…
2 parents 1012da7 + 0fca2a3 commit 0ae568c

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

local_builds/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Download and use our codebuild_build.sh script to run your local builds.
2828
-c Use the AWS configuration and credentials from your local host. This includes ~/.aws and any AWS_* environment variables.
2929
-b Used to specify a buildspec override file. Defaults to buildspec.yml in the source directory.
3030
-e Used to specify a file containing environment variables.
31+
-m Used to mount the source directory to the customer build container directly.
3132

3233
**Environment variable file format:**
3334
* Expects each line to be in VAR=VAL format

local_builds/codebuild_build.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ function usage {
3939
echo " -c Use the AWS configuration and credentials from your local host. This includes ~/.aws and any AWS_* environment variables."
4040
echo " -b Used to specify a buildspec override file. Defaults to buildspec.yml in the source directory."
4141
echo " -e Used to specify a file containing environment variables."
42+
echo " -m Used to mount the source directory to the customer build container directly."
4243
echo " Environment variable file format:"
4344
echo " * Expects each line to be in VAR=VAL format"
4445
echo " * Lines beginning with # are processed as comments and ignored"
@@ -51,13 +52,15 @@ function usage {
5152
image_flag=false
5253
artifact_flag=false
5354
awsconfig_flag=false
55+
mount_src_dir_flag=false
5456

55-
while getopts "ci:a:s:b:e:l:h" opt; do
57+
while getopts "cmi:a:s:b:e:l:h" opt; do
5658
case $opt in
5759
i ) image_flag=true; image_name=$OPTARG;;
5860
a ) artifact_flag=true; artifact_dir=$OPTARG;;
5961
b ) buildspec=$OPTARG;;
6062
c ) awsconfig_flag=true;;
63+
m ) mount_src_dir_flag=true;;
6164
s ) source_dir=$OPTARG;;
6265
e ) environment_variable_file=$OPTARG;;
6366
l ) local_agent_image=$OPTARG;;
@@ -120,7 +123,7 @@ then
120123
docker_command+=" -e \"LOCAL_AGENT_IMAGE_NAME=$local_agent_image\""
121124
fi
122125

123-
if $awsconfig_flag
126+
if $awsconfig_flag
124127
then
125128
if [ -d "$HOME/.aws" ]
126129
then
@@ -132,6 +135,11 @@ then
132135
docker_command+="$(env | grep ^AWS_ | while read -r line; do echo " -e \"$line\""; done )"
133136
fi
134137

138+
if $mount_src_dir_flag
139+
then
140+
docker_command+=" -e \"MOUNT_SOURCE_DIRECTORY=TRUE\""
141+
fi
142+
135143
if isOSWindows
136144
then
137145
docker_command+=" -e \"INITIATOR=$USERNAME\""

0 commit comments

Comments
 (0)