11# Jenkins CI script for Windows to Linux CI.
22# Heavily modified by John Howard (@jhowardmsft) December 2015 to try to make it more reliable.
33set +xe
4- SCRIPT_VER=" Thu Feb 25 18:54:57 UTC 2016"
4+ SCRIPT_VER=" Wed Apr 20 18:30:19 UTC 2016"
55
6- # TODO to make (even) more resilient:
6+ # TODO to make (even) more resilient:
77# - Wait for daemon to be running before executing docker commands
88# - Check if jq is installed
99# - Make sure bash is v4.3 or later. Can't do until all Azure nodes on the latest version
@@ -78,7 +78,7 @@ if [ $ec -eq 0 ]; then
7878 ping $ip
7979 else
8080 echo " INFO: The Linux nodes outer daemon replied to a ping. Good!"
81- fi
81+ fi
8282fi
8383
8484# Get the version from the remote node. Note this may fail if jq is not installed.
@@ -103,6 +103,16 @@ if [ $ec -eq 0 ]; then
103103 fi
104104fi
105105
106+ # Are we in split binary mode?
107+ if [ ` grep DOCKER_CLIENTONLY Makefile | wc -l` -gt 0 ]; then
108+ splitBinary=0
109+ echo " INFO: Running in single binary mode"
110+ else
111+ splitBinary=1
112+ echo " INFO: Running in split binary mode"
113+ fi
114+
115+
106116# Get the commit has and verify we have something
107117if [ $ec -eq 0 ]; then
108118 export COMMITHASH=$( git rev-parse --short HEAD)
119129# will cause CI to fail from Windows to Linux. Obviously it's not best practice to ever run as local system...
120130if [ $ec -eq 0 ]; then
121131 export TEMP=/c/CI/CI-$COMMITHASH
122- export TMP=$TMP
132+ export TMP=$TEMP
123133 /usr/bin/mkdir -p $TEMP # Make sure Linux mkdir for -p
124134fi
125135
126136# Tidy up time
127137if [ $ec -eq 0 ]; then
128138 echo INFO: Deleting pre-existing containers and images...
139+
129140 # Force remove all containers based on a previously built image with this commit
130141 ! docker rm -f $( docker ps -aq --filter " ancestor=docker:$COMMITHASH " ) & > /dev/null
131-
142+
132143 # Force remove any container with this commithash as a name
133144 ! docker rm -f $( docker ps -aq --filter " name=docker-$COMMITHASH " ) & > /dev/null
134145
135- # Force remove the image if it exists
136- ! docker rmi -f " docker-$COMMITHASH " & > /dev/null
137-
138146 # This SHOULD never happen, but just in case, also blow away any containers
139147 # that might be around.
140- ! if [ ! ` docker ps -aq | wc -l` -eq 0 ]; then
148+ ! if [ ! $( docker ps -aq | wc -l) -eq 0 ]; then
141149 echo WARN: There were some leftover containers. Cleaning them up.
142150 ! docker rm -f $( docker ps -aq)
143151 fi
152+
153+ # Force remove the image if it exists
154+ ! docker rmi -f " docker-$COMMITHASH " & > /dev/null
144155fi
145156
146- # Provide the docker version for debugging purposes. If these fail, game over.
157+ # Provide the docker version for debugging purposes. If these fail, game over.
147158# as the Linux box isn't responding for some reason.
148159if [ $ec -eq 0 ]; then
149160 echo INFO: Docker version and info of the outer daemon on the Linux node
170181# build the daemon image
171182if [ $ec -eq 0 ]; then
172183 echo " INFO: Running docker build on Linux host at $DOCKER_HOST "
173- set -x
174- docker build --rm --force-rm -t " docker:$COMMITHASH " .
184+ if [ $splitBinary -eq 0 ]; then
185+ set -x
186+ docker build --rm --force-rm --build-arg APT_MIRROR=cdn-fastly.deb.debian.org -t " docker:$COMMITHASH " .
187+ cat << EOF | docker build --rm --force-rm -t "docker:$COMMITHASH " -
188+ FROM docker:$COMMITHASH
189+ RUN hack/make.sh binary
190+ RUN cp bundles/latest/binary/docker /bin/docker
191+ CMD docker daemon -D -H tcp://0.0.0.0:$port_inner $daemon_extra_args
192+ EOF
193+ else
194+ set -x
195+ docker build --rm --force-rm --build-arg APT_MIRROR=cdn-fastly.deb.debian.org -t " docker:$COMMITHASH " .
196+ cat << EOF | docker build --rm --force-rm -t "docker:$COMMITHASH " -
197+ FROM docker:$COMMITHASH
198+ RUN hack/make.sh binary
199+ RUN cp bundles/latest/binary-daemon/dockerd /bin/dockerd
200+ CMD dockerd -D -H tcp://0.0.0.0:$port_inner $daemon_extra_args
201+ EOF
202+
203+ fi
175204 ec=$?
176205 set +x
177206 if [ 0 -ne $ec ]; then
@@ -184,24 +213,25 @@ if [ $ec -eq 0 ]; then
184213 echo " INFO: Starting build of a Linux daemon to test against, and starting it..."
185214 set -x
186215 # aufs in aufs is faster than vfs in aufs
187- docker run $run_extra_args -e DOCKER_GRAPHDRIVER=aufs --pid host --privileged -d -- name " docker-$COMMITHASH " --net host " docker:$COMMITHASH " bash -c " echo 'INFO: Compiling' && date && hack/make.sh binary && echo 'INFO: Compile complete' && date && cp bundles/ $( cat VERSION ) /binary/docker /bin/docker && echo 'INFO: Starting daemon' && exec docker daemon -D -H tcp://0.0.0.0: $port_inner $daemon_extra_args "
216+ docker run -d $run_extra_args -e DOCKER_GRAPHDRIVER=aufs --pid host --privileged -- name " docker-$COMMITHASH " --net host " docker:$COMMITHASH "
188217 ec=$?
189218 set +x
190219 if [ 0 -ne $ec ]; then
191- echo " ERROR: Failed to compile and start the linux daemon"
220+ echo " ERROR: Failed to compile and start the linux daemon"
192221 fi
193222fi
194223
195224# Build locally.
196225if [ $ec -eq 0 ]; then
197226 echo " INFO: Starting local build of Windows binary..."
198227 set -x
199- export TIMEOUT=" 5m "
228+ export TIMEOUT=" 120m "
200229 export DOCKER_HOST=" tcp://$ip :$port_inner "
230+ # This can be removed
201231 export DOCKER_TEST_HOST=" tcp://$ip :$port_inner "
202232 unset DOCKER_CLIENTONLY
203233 export DOCKER_REMOTE_DAEMON=1
204- hack/make.sh binary
234+ hack/make.sh binary
205235 ec=$?
206236 set +x
207237 if [ 0 -ne $ec ]; then
212242# Make a local copy of the built binary and ensure that is first in our path
213243if [ $ec -eq 0 ]; then
214244 VERSION=$( < ./VERSION)
215- cp bundles/$VERSION /binary/docker.exe $TEMP
245+ if [ $splitBinary -eq 0 ]; then
246+ cp bundles/$VERSION /binary/docker.exe $TEMP
247+ else
248+ cp bundles/$VERSION /binary-client/docker.exe $TEMP
249+ fi
216250 ec=$?
217251 if [ 0 -ne $ec ]; then
218252 echo " ERROR: Failed to copy built binary to $TEMP "
@@ -221,19 +255,20 @@ if [ $ec -eq 0 ]; then
221255fi
222256
223257# Run the integration tests
224- if [ $ec -eq 0 ]; then
258+ if [ $ec -eq 0 ]; then
225259 echo " INFO: Running Integration tests..."
226260 set -x
227261 export DOCKER_TEST_TLS_VERIFY=" $DOCKER_TLS_VERIFY "
228262 export DOCKER_TEST_CERT_PATH=" $DOCKER_CERT_PATH "
263+ # export TESTFLAGS='-check.vv'
229264 hack/make.sh test-integration-cli
230265 ec=$?
231266 set +x
232267 if [ 0 -ne $ec ]; then
233268 echo " ERROR: CLI test failed."
234269 # Next line is useful, but very long winded if included
235- # docker -H=$MAIN_DOCKER_HOST logs "docker-$COMMITHASH"
236- fi
270+ docker -H=$MAIN_DOCKER_HOST logs --tail 100 " docker-$COMMITHASH "
271+ fi
237272fi
238273
239274# Tidy up any temporary files from the CI run
267302
268303# Tell the user how we did.
269304if [ $ec -eq 0 ]; then
270- echo INFO: Completed successfully at ` date` .
305+ echo INFO: Completed successfully at ` date` .
271306else
272307 echo ERROR: Failed with exitcode $ec at ` date` .
273308fi
0 commit comments