发布于 2016-01-14 09:14:23 | 224 次阅读 | 评论: 0 | 来源: PHPERZ

这里有新鲜出炉的精品教程,程序狗速度看过来!

Jenkins 持续集成引擎

Jenkins 的前身是 Hudson 是一个可扩展的持续集成引擎。


最近在搞jenkins + docker CI,把自己写的集成脚本分享出来给大家。里面很多路径或者名称是我自己的,自行替换掉。

#!/bin/sh
# Jenkins Build Shell Script
# Author zdzhou@iflytek.com

set -e 
# Get running docker image name
cid=`docker ps | grep 'isearch' | awk {'print $1'}`
echo $cid

# If exists running isearch docker image, stop and remove it
if [ -n "$cid" ]
then
    echo Get the running docker container id of isearch: $cid
    docker stop $cid
    docker rm $cid
else  
    echo There is no running isearch docker container
fi

# Copy target war to dest directory
cd ${JENKINS_HOME}/workspace/${JOB_NAME}/itv-web/
echo Current work directory `pwd`
cp target/itv-web.war /usr/local/tomcat/webapps
echo Run docker image
docker run -d -p 8080:8080 -v /usr/local/isearch:/usr/local/isearch -v /usr/local/tomcat/webapps:/usr/local/tomcat/webapps --name=isearch${SVN_REVISION} isearch

# Wait for starting docker container
totalWait=0
until [ "`/usr/bin/docker inspect -f {{.State.Running}} isearch${SVN_REVISION}`" == "true" ] 
do
   totalWait=$[ $totalWait + 2 ]
   if (( $totalWait > 10 ))
   then
      echo "Start docker container timeout"
      exit 1
   fi
   echo "Waiting for starting docker container: $totalWait minute" 
   sleep 2m
done
echo "Start docker container success "

# Wait for starting tomcat
totalWait=0
until [ "`curl -o /dev/null --silent -m 10 --retry 1 --connect-timeout 10 --head --write-out '%{http_code}\n' http://127.0.0.1:8080/itv-web/v3/videosearch/?appid=aginomoto`" = "200" ]
do 
  totalWait=$[ $totalWait + 3 ]
  if (($totalWait > 36 ))
  then 
    echo "Start tomcat timeout"
    exit 1
  fi
  echo "Wait for starting tomcat: "$totalWait" minute"
  sleep 3m
done 
echo "Start tomcat service success"

# Run automatic function test script
echo "Start automatic function test"
export LOG_HOME=${WORKSPACE}/test.log.d/${BUILD_NUMBER}
cd /data/jenkins_home/test.framework.d
exec ./automatic_test.sh 


最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务