Skip to content

Commit af2ef98

Browse files
committed
Add support for running local agent on Windows
1 parent b589164 commit af2ef98

File tree

1 file changed

+38
-9
lines changed

1 file changed

+38
-9
lines changed

local_builds/codebuild_build.sh

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,31 @@
11
#!/bin/bash
22

33
function allOSRealPath() {
4-
case $1 in
5-
/* ) echo "$1"; exit;;
6-
* ) echo "$PWD/${1#./}"; exit;;
7-
esac
4+
if isOSWindows
5+
then
6+
path=""
7+
case $1 in
8+
.* ) path="$PWD/${1#./}" ;;
9+
/* ) path="$1" ;;
10+
* ) path="/$1" ;;
11+
esac
12+
13+
echo "/$path" | sed -e 's/\\/\//g' -e 's/://' -e 's/./\U&/3'
14+
else
15+
case $1 in
16+
/* ) echo "$1"; exit;;
17+
* ) echo "$PWD/${1#./}"; exit;;
18+
esac
19+
fi
20+
}
21+
22+
function isOSWindows() {
23+
if [ $OSTYPE == "msys" ]
24+
then
25+
return 0
26+
else
27+
return 1
28+
fi
829
}
930

1031
function usage {
@@ -62,13 +83,20 @@ fi
6283

6384
if [ -z "$source_dir" ]
6485
then
65-
source_dir="$(pwd)"
86+
source_dir=$(allOSRealPath $PWD)
6687
else
6788
source_dir=$(allOSRealPath $source_dir)
6889
fi
6990

70-
docker_command="docker run -it -v /var/run/docker.sock:/var/run/docker.sock -e \
71-
\"IMAGE_NAME=$image_name\" -e \
91+
docker_command="docker run -it "
92+
if isOSWindows
93+
then
94+
docker_command+="-v //var/run/docker.sock:/var/run/docker.sock -e "
95+
else
96+
docker_command+="-v /var/run/docker.sock:/var/run/docker.sock -e "
97+
fi
98+
99+
docker_command+="\"IMAGE_NAME=$image_name\" -e \
72100
\"ARTIFACTS=$(allOSRealPath $artifact_dir)\" -e \
73101
\"SOURCE=$source_dir\""
74102

@@ -89,7 +117,8 @@ if $awsconfig_flag
89117
then
90118
if [ -d "$HOME/.aws" ]
91119
then
92-
docker_command+=" -e \"AWS_CONFIGURATION=$HOME/.aws\""
120+
configuration_file_path=$(allOSRealPath "$HOME/.aws")
121+
docker_command+=" -e \"AWS_CONFIGURATION=$configuration_file_path\""
93122
else
94123
docker_command+=" -e \"AWS_CONFIGURATION=NONE\""
95124
fi
@@ -111,4 +140,4 @@ echo ""
111140
echo $exposed_command
112141
echo ""
113142

114-
eval $docker_command
143+
eval $docker_command

0 commit comments

Comments
 (0)