Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion local_builds/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ Download and use our codebuild_build.sh script to run your local builds.

**Optional:**
-l Used to override the default local agent image.
-s Used to specify a source directory. Defaults to the current working directory.
-c Use the AWS configuration and credentials from your local host. This includes ~/.aws and any AWS_* environment variables.
-b Used to specify a buildspec override file. Defaults to buildspec.yml in the source directory.
-e Used to specify a file containing environment variables.
-m Used to mount the source directory to the customer build container directly.
-s Used to specify a source directory. Defaults to the current working directory.
* First (-s) is for primary source
* Use additional (-s) in `<sourceIdentifier>:<sourceLocation>` format for secondary source
* For `sourceIdentifier`, use a value that is fewer than 128 characters and contains only alphanumeric characters and underscores

**Environment variable file format:**
* Expects each line to be in VAR=VAL format
Expand Down
36 changes: 24 additions & 12 deletions local_builds/codebuild_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ function usage {
echo " -a Used to specify an artifact output directory."
echo "Options:"
echo " -l IMAGE Used to override the default local agent image."
echo " -s DIR Used to specify a source directory. Defaults to the current working directory."
echo " -s Used to specify source information. Defaults to the current working directory for primary source."
echo " * First (-s) is for primary source"
echo " * Use additional (-s) in <sourceIdentifier>:<sourceLocation> format for secondary source"
echo " * For sourceIdentifier, use a value that is fewer than 128 characters and contains only alphanumeric characters and underscores"
echo " -c Use the AWS configuration and credentials from your local host. This includes ~/.aws and any AWS_* environment variables."
echo " -b FILE Used to specify a buildspec override file. Defaults to buildspec.yml in the source directory."
echo " -m Used to mount the source directory to the customer build container directly."
Expand All @@ -61,7 +64,7 @@ while getopts "cmi:a:s:b:e:l:h" opt; do
b ) buildspec=$OPTARG;;
c ) awsconfig_flag=true;;
m ) mount_src_dir_flag=true;;
s ) source_dir=$OPTARG;;
s ) source_dirs+=("$OPTARG");;
e ) environment_variable_file=$OPTARG;;
l ) local_agent_image=$OPTARG;;
h ) usage; exit;;
Expand All @@ -86,13 +89,6 @@ then
exit 1
fi

if [ -z "$source_dir" ]
then
source_dir=$(allOSRealPath $PWD)
else
source_dir=$(allOSRealPath $source_dir)
fi

docker_command="docker run -it "
if isOSWindows
then
Expand All @@ -102,8 +98,24 @@ else
fi

docker_command+="\"IMAGE_NAME=$image_name\" -e \
\"ARTIFACTS=$(allOSRealPath $artifact_dir)\" -e \
\"SOURCE=$source_dir\""
\"ARTIFACTS=$(allOSRealPath $artifact_dir)\""

if [ -z "$source_dirs" ]
then
docker_command+=" -e \"SOURCE=$(allOSRealPath $PWD)\""
else
for index in "${!source_dirs[@]}"; do
if [ $index -eq 0 ]
then
docker_command+=" -e \"SOURCE=$(allOSRealPath ${source_dirs[$index]})\""
else
identifier=${source_dirs[$index]%%:*}
src_dir=$(allOSRealPath ${source_dirs[$index]#*:})

docker_command+=" -e \"SECONDARY_SOURCE_$index=$identifier:$src_dir\""
fi
done
fi

if [ -n "$buildspec" ]
then
Expand Down Expand Up @@ -162,4 +174,4 @@ echo ""
echo $exposed_command
echo ""

eval $docker_command
eval $docker_command