Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Bamboo Docker Runner

When docker runner is used, Bamboo executes a series of Base scripts;initialiseDockerContainer.sh.

  1. 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 | sed -e s@^${homeMountsInContainer}/@@ -e s@/${DELIMITER}@@)
     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

     

  2. 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

  3. And finally the script where all the work is done;
    • #!/bin/sh
       docker cp /home/voseghale/workdir/runInDocker.sh 645b8d62-6205-3949-bdc9-439124a0b33b654330:/tmp/runInDocker1111111.sh 
       docker exec -u root 645b8d62-6205-3949-bdc9-439124a0b33b654330 chown root:root /tmp/runInDocker1111111.sh
       docker exec -u root 645b8d62-6205-3949-bdc9-439124a0b33b654330 chmod 755 /tmp/rrunInDocker1111111.sh
       docker exec -e 'bamboo_planRepository_1_branch=master' -e 'bamboo_build_commandline__1000031=/usr/bin/docker exec 31ab8d62-6205-4949-bdc9-729124a0b33b688130 /tmp/initialiseContainer.sh' -e 'bamboo_planRepo
      7sitory_1_branchDisplayName=master' -e 'bamboo_repository_revision_number=33365ece288a1f2fa284a26d56639718f14765be' -e 'MAVEN2_HOME=/usr' -e 'bamboo_resultsUrl=http://192.168.1.116:8086/browse/TEST-TES4-JOB
      81-39'.... \tmp\runInDocker6133634956987747987.sh

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

0 comments

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events