-
Notifications
You must be signed in to change notification settings - Fork 1
Docker Commands Preperartion
doronshai edited this page Feb 16, 2017
·
1 revision
#!/bin/bash -ex
DOCKER_WORKDIR=${1}
CURRENT_BRANCH=${2}
PLATFORM=${3}
#Prepare docker commands variables
if [ "$BUILD_FLOW" = "CI" ]; then
DOCKER_BUILD_CMD="sudo docker build -t xxx-ci-${CURRENT_BRANCH}/${PLATFORM} scripts/docker/$PLATFORM"
DOCKER_RUN_CMD="sudo docker run --rm -w "$DOCKER_WORKDIR" -e "BUILD_NUMBER=$BUILD_NUMBER" -e "WORKSPACE=/mnt/xxx" -e "BUILD_VERSION=$BUILD_VERSION" -v ${WORKSPACE}:/mnt/xxx -v /tmp/.npm/${PLATFORM}:/root/.npm xxx-ci-${CURRENT_BRANCH}/${Platform}"
elif [ "$BUILD_FLOW" = "PRIVATE" ]; then
DOCKER_BUILD_CMD="sudo docker build -t xxx-private-${CURRENT_BRANCH}/${PLATFORM} scripts/docker/$PLATFORM"
DOCKER_RUN_CMD="sudo docker run --rm -w "$DOCKER_WORKDIR" -e "BUILD_NUMBER=$BUILD_NUMBER" -e "WORKSPACE=/mnt/xxx" -e "BUILD_VERSION=$BUILD_VERSION" -v ${WORKSPACE}:/mnt/xxx -v /tmp/.npm/${PLATFORM}:/root/.npm xxx-private-${CURRENT_BRANCH}/${PLATFORM}"
else
DOCKER_BUILD_CMD="sudo docker build -t xxx-${CURRENT_BRANCH}/${PLATFORM} scripts/docker/$PLATFORM"
DOCKER_RUN_CMD="sudo docker run --rm -w "$DOCKER_WORKDIR" -e "BUILD_NUMBER=$BUILD_NUMBER" -e "WORKSPACE=/mnt/xxx" -e "BUILD_VERSION=$BUILD_VERSION" -v ${WORKSPACE}:/mnt/xxx -v /tmp/.npm/${PLATFORM}:/root/.npm xxx-${CURRENT_BRANCH}/${PLATFORM}"
fi
Then write these Env Variables to a properties file and inject it to Jenkins build