When docker runner is used, Bamboo executes a series of Base scripts;initialiseDockerContainer.sh.
- this creates symlinks in a running docker container. This will only run completely in case volume mount bindings were provided using relative path ~
#!/bin/sh
DELIMITER=123_MOUNTPOINT_321
homeMountsInContainer=/tmp/homemountpoints
if [ ! -d ${homeMountsInContainer} ] ; then
exit
fi
for mountPoint in $(find ${homeMountsInContainer} -type d -name ${DELIMITER} -prune) ; do
relativePath=$(echo $mountPoint@)
echo Processing $relativePath ...
target=~/${relativePath}
if mountpoint -q "${target}" ; then
rm -rf ${target} 2>/dev/null
echo Rewiring contents of ${mountPoint} to mount point ${target}
for entry in $(ls -A ${mountPoint}) ; do
ln -s "${mountPoint}/${entry}" ${target}
done
else
echo Rewiring ${mountPoint} to ${target}
rm -rf ${target}
mkdir -p $(dirname ${target})
ln -s "${mountPoint}" "${target}"
fi
done
rm $0
-
After the container is considered initialized Bamboo will generate 2 scripts per each task in a job runInDocker<DIGITS>.sh with the exemption of a script task which has 3 scripts (where the 3rd is the body of the script task).
Here is a simple Script Task which created script runInDocker1111111.sh
-
#!/bin/sh
cd 'C:\Users\voseg\bamboo-home\local-working-dir\DEV-DTIDR-JOB1'
umask 000
'C:\Users\voseg\bamboo-home\temp\DEV-DTIDR-JOB1-22-ScriptBuildTask-11319997664902311449.bat'
exit $?
this wraps the body of the script task DEV-DTIDR-JOB1-22-ScriptBuildTask-11319997664902311449.bat
- And finally the script where all the work is done;
In summary when a Job in Isolated build in Docker container, Bamboo:
- generates a script with each task in the job in a temp directory on the server file system
- generates another script that:
- copies the task script to a running container (docker cp)
- changes permissions and ownership (docker exec ${command})
- executes the task script - huge docker exec with all the default and and user provided variables