aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/jenkins/run_jenkins.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tools/jenkins/run_jenkins.sh')
-rwxr-xr-xtools/jenkins/run_jenkins.sh28
1 files changed, 25 insertions, 3 deletions
diff --git a/tools/jenkins/run_jenkins.sh b/tools/jenkins/run_jenkins.sh
index a95819af60..57cec77424 100755
--- a/tools/jenkins/run_jenkins.sh
+++ b/tools/jenkins/run_jenkins.sh
@@ -41,13 +41,35 @@ if [ "$platform" == "linux" ]
then
echo "building $language on Linux"
+ if [ "$ghprbPullId" != "" ]
+ then
+ # if we are building a pull request, grab corresponding refs.
+ FETCH_PULL_REQUEST_CMD="&& git fetch $GIT_URL refs/pull/$ghprbPullId/merge refs/pull/$ghprbPullId/head"
+ fi
+
+ # Make sure the CID file is gone.
+ rm -f docker.cid
+
# Run tests inside docker
- docker run grpc/grpc_jenkins_slave bash -c -l "git clone --recursive $GIT_URL /var/local/git/grpc \
- && cd /var/local/git/grpc && git checkout -f $GIT_COMMIT \
+ docker run --cidfile=docker.cid grpc/grpc_jenkins_slave bash -c -l "git clone --recursive $GIT_URL /var/local/git/grpc \
+ && cd /var/local/git/grpc \
+ $FETCH_PULL_REQUEST_CMD \
+ && git checkout -f $GIT_COMMIT \
&& git submodule update \
&& nvm use 0.12 \
&& rvm use ruby-2.1 \
- && tools/run_tests/run_tests.py -t -l $language"
+ && tools/run_tests/run_tests.py -t -l $language" || DOCKER_FAILED="true"
+
+ DOCKER_CID=`cat docker.cid`
+ if [ "$DOCKER_FAILED" == "" ]
+ then
+ echo "Docker finished successfully, deleting the container $DOCKER_CID"
+ docker rm $DOCKER_CID
+ else
+ echo "Docker exited with failure, keeping container $DOCKER_CID."
+ echo "You can SSH to the worker and use 'docker start CID' and 'docker exec -i -t CID bash' to debug the problem."
+ fi
+
elif [ "$platform" == "windows" ]
then
echo "building $language on Windows"