自由风格
代码拉取
https://gitee.com/iXiAo9/jenkins-nginx-demo
Jenkins构建
#!/bin/sh
#
QWQ=`docker images | grep nginx_ | awk '{print $3}'`
docker rmi $QWQ
DATE=`date +%m%d%H%M `
#DIR="/var/lib/jenkins/jobs/nginx/workspace/"
DIR="."
docker build -t nginx_$DATE $DIR | tee $DIR/Docker_build_result.log
#RESULT=$(cat $DIR/Docker_build_result.log | tail -n 1)
#if [["$RESULT" != *Successfully*]];then
# exit -1
#fi
docker run -dit --net=host --name nginx_$DATE nginx_$DATE
docker tag nginx_$DATE:latest 192.168.10.12/library/nginx_$DATE:latest
docker push 192.168.10.12/library/nginx_$DATE:latest
docker rmi 192.168.10.12/library/nginx_$DATE:latest