echo '============查看打包环境================'
pwd
ls
echo $PATH
whoami
# which dotnet
# dotnet --info
# dotnet --version
echo '============================begin restore======================================='
# dotnet restore
echo '============================end restore======================================='
echo '============================cd project======================================='
cd ./dockerTest
echo '============================begin build======================================='
# dotnet build
rm -rf $WORKSPACE/jenkins_publish
mkdir $WORKSPACE/jenkins_publish
echo $WORKSPACE '------'
cp $WORKSPACE/dockerTest/bin/Debug/netcoreapp2.1/* $WORKSPACE/jenkins_publish/
echo '============================end build======================================='
# 切换到源码目录,对应在jenkins的workspace下面
cd $WORKSPACE/jenkins_publish
image_version=`date +%Y%m%d%H%M`;
echo $image_version;
# 停止之前的docker container
docker stop dockertestj;
# 删除这个container
docker rm dockertestj;
# build镜像并且打上tag
docker build -t dockertestj_$image_version .;
docker images;
# 把刚刚build出来的镜像跑起来
docker run -p 82:80 -v ~/docker-data/dockertestj/appsettings.json:/app/appsettings.json -v ~/docker-data/dockertestj/NLogFile/:/app/NLogFile --restart=always --name dockertestj -d dockertestj_$image_version;
docker logs dockertestj;