|
@@ -75,6 +75,49 @@ pipeline {
|
|
|
'''
|
|
|
}
|
|
|
}
|
|
|
+ stage("Publish") {
|
|
|
+ steps {
|
|
|
+ echo "Publishing ${DOCKER_REGISTRY}/${DOCKER_IMAGE}:${BUILD_NUMBER}."
|
|
|
+ sh "docker push ${DOCKER_REGISTRY}/${DOCKER_IMAGE}:${BUILD_NUMBER}"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ stage("Prod-like") {
|
|
|
+ steps {
|
|
|
+ echo "Check Prod-like cluster status"
|
|
|
+ sh '''ping -c 2 ${CLUSTER_NAME}
|
|
|
+ if [ $? -eq 0 ]; then
|
|
|
+ export DOCKER_CERT_PATH=/run/secrets/swarm
|
|
|
+ export DOCKER_HOST=tcp://${CLUSTER_NAME}:2376 DOCKER_TLS_VERIFY=1
|
|
|
+ docker node ls --format "{{.Hostname}} {{.TLSStatus}}" | while read host status
|
|
|
+ do
|
|
|
+ if [ $status != Ready ]; then echo "Cluster ${CLUSTER_NAME} state is inconsistent"; exit 1
|
|
|
+ else echo "HOST: $host STATUS: $status"
|
|
|
+ fi
|
|
|
+ done
|
|
|
+ else echo "Host not Found"; exit 1
|
|
|
+ fi
|
|
|
+ '''
|
|
|
+ echo "Run containers in Prod-like"
|
|
|
+ sh '''export DOCKER_CERT_PATH=/run/secrets/swarm
|
|
|
+ export DOCKER_HOST=tcp://dev-iru-swarm1.infoclinica.lan:2376 DOCKER_TLS_VERIFY=1
|
|
|
+ if [ !$(docker service ps -q ${DOCKER_IMAGE}) ];then
|
|
|
+ docker service create --replicas 2 \
|
|
|
+ --mount type=bind,source=/var/run/docker.sock,destination=/var/run/docker.sock \
|
|
|
+ --name ${SERVICE_NAME} ${DOCKER_REGISTRY}/${SERVICE_IMAGE}:1 -p 1194:1194 \
|
|
|
+ --privileged --security-opt seccomp=unconfined \
|
|
|
+ --tmpfs /run --tmpfs /run/lock -v /sys/fs/cgroup:/sys/fs/cgroup:ro \
|
|
|
+ -e "mode=server" ${DOCKER_REGISTRY}/${DOCKER_IMAGE}:${BUILD_NUMBER}
|
|
|
+ else
|
|
|
+ docker service update \
|
|
|
+ --args "-p 1194:1194 --privileged --security-opt seccomp=unconfined \
|
|
|
+ --tmpfs /run --tmpfs /run/lock -v /sys/fs/cgroup:/sys/fs/cgroup:ro \
|
|
|
+ -e "mode=server" ${DOCKER_REGISTRY}/${DOCKER_IMAGE}:${BUILD_NUMBER}" \
|
|
|
+ ${SERVICE_NAME}
|
|
|
+ if [ $? != 0 ]; then docker service rollback ${SERVICE_NAME}; fi
|
|
|
+ fi
|
|
|
+ '''
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
post {
|
|
|
always {
|