updated jenkinsfile
This commit is contained in:
40
Jenkinsfile
vendored
40
Jenkinsfile
vendored
@@ -11,32 +11,32 @@ pipeline {
|
||||
stage('Publish') {
|
||||
steps {
|
||||
sh '''if [ ! "$(docker ps -q -f name=worldcraftdiscordbot_1)" ]; then
|
||||
if [ "$(docker ps -aq -f status=exited -f name=worldcraftdiscordbot_1)" ]; then
|
||||
# cleanup
|
||||
docker rm worldcraftdiscordbot_1
|
||||
fi
|
||||
# run your container
|
||||
NEW=worldcraftdiscordbot_1
|
||||
OLD=worldcraftdiscordbot_2
|
||||
docker run -d --name worldcraftdiscordbot_1 --restart unless-stopped worldcraftdiscordbot:v${env.BUILD_ID}
|
||||
if [ "$(docker ps -aq -f status=exited -f name=worldcraftdiscordbot_1)" ]; then
|
||||
# cleanup
|
||||
docker rm<EFBFBD>worldcraftdiscordbot_1
|
||||
fi
|
||||
# run your container
|
||||
NEW=worldcraftdiscordbot_1
|
||||
OLD=worldcraftdiscordbot_2
|
||||
docker run -d --name worldcraftdiscordbot_1 --restart unless-stopped worldcraftdiscordbot:v${env.BUILD_ID}
|
||||
else [ ! "$(docker ps -q -f name=worldcraftdiscordbot_2)" ]; then
|
||||
if [ "$(docker ps -aq -f status=exited -f name=worldcraftdiscordbot_2)" ]; then
|
||||
# cleanup
|
||||
docker rm worldcraftdiscordbot_2
|
||||
fi
|
||||
NEW=worldcraftdiscordbot_2
|
||||
OLD=worldcraftdiscordbot_1
|
||||
# run your container
|
||||
docker run -d --name $NEW --restart unless-stopped worldcraftdiscordbot:v${env.BUILD_ID}
|
||||
if [ "$(docker ps -aq -f status=exited -f name=worldcraftdiscordbot_2)" ]; then
|
||||
# cleanup
|
||||
docker rm worldcraftdiscordbot_2
|
||||
fi
|
||||
NEW=worldcraftdiscordbot_2
|
||||
OLD=worldcraftdiscordbot_1
|
||||
# run your container
|
||||
docker run -d --name $NEW --restart unless-stopped worldcraftdiscordbot:v${env.BUILD_ID}
|
||||
fi
|
||||
|
||||
# remove old container after 3 seconds
|
||||
if [ "$(docker ps -a -f name=$OLD)" ]; then
|
||||
sleep 3s
|
||||
docker stop $OLD
|
||||
if [ "$(docker ps -a -f name=$OLD)" ]; then
|
||||
sleep 3s
|
||||
docker stop $OLD
|
||||
fi'''
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user