github.com/vmware/go-vcloud-director/v2@v2.24.0/support/run_in_docker.sh (about) 1 #!/usr/bin/env bash 2 3 SHOME=`dirname $0` 4 cd $SHOME 5 6 SRCROOT=`cd ..; pwd` 7 cd $SRCROOT 8 9 DESTINATION_SRC=/go/src/github.com/vmware/go-vcloud-director 10 11 # Build the Docker image using the current uid/gid so 12 # repeat iterations of the Jenkins environment can 13 # properly cleanup the workspace. 14 DOCKER_BUILD=`docker build -q \ 15 --build-arg build_user=${USER} \ 16 --build-arg build_uid=$(id -u) \ 17 --build-arg build_gid=$(id -g) \ 18 -f support/Dockerfile.jenkins \ 19 support` 20 DOCKER_IMAGE=`echo $DOCKER_BUILD | awk -F: '{print $2}'` 21 22 # Include VCD_CONNECTION as a mounted file and environment variable 23 VCD_ARGS="" 24 if [ "$GOVCD_CONFIG" != "" ]; then 25 VCD_ARGS="-eGOVCD_CONFIG=$GOVCD_CONFIG -v$GOVCD_CONFIG:$GOVCD_CONFIG" 26 echo "$VCD_ARGS" 27 else 28 # If the GOVCD configuration is not set, we can't run the tests 29 # So we interrupt as early as possible and then investigate 30 echo "$0: GOVCD_CONFIG not set" 31 exit 1 32 fi 33 34 # Run the Docker container with source code mounted along 35 # with additional files and environment variables 36 docker run --rm \ 37 $VCD_ARGS \ 38 --name=govcd_test \ 39 --hostname=govcd_test \ 40 -v$SRCROOT:$DESTINATION_SRC \ 41 -w$DESTINATION_SRC \ 42 $DOCKER_IMAGE \ 43 /bin/bash -c "$*" 44 45 EC=$? 46 if [ $EC -ne 0 ]; then 47 exit $EC 48 fi