diff --git a/Jenkinsfile b/Jenkinsfile index 7137c1c..36be2c3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,3 +1,6 @@ +// STACK_NAME defines the name of the Docker stack deployed to acceptance +def STACK_NAME="lab-data-streamer" + pipeline { agent any @@ -71,7 +74,7 @@ pipeline { } steps { - sh 'docker stack rm streamer4user' + sh "docker stack rm ${STACK_NAME}" sleep(30) @@ -100,7 +103,7 @@ pipeline { // Use the same approach as for production script { - def statusCode = sh(script: "bash ./docker-deploy-acceptance.sh", returnStatus: true) + def statusCode = sh(script: "bash ./docker-deploy-acceptance.sh ${STACK_NAME}", returnStatus: true) echo "statusCode: ${statusCode}" } } @@ -117,7 +120,7 @@ pipeline { label 'swarm-manager' } steps { - withDockerContainer(image: 'jwilder/dockerize', args: '--network lab-data-streamer_default') { + withDockerContainer(image: 'jwilder/dockerize', args: "--network ${STACK_NAME}_default") { sh ( label: 'Waiting for services to become available', script: 'dockerize \ @@ -133,11 +136,11 @@ pipeline { failure { sh ( label: 'Displaying service status', - script: 'docker stack ps streamer4user' + script: "docker stack ps ${STACK_NAME}" ) sh ( label: 'Displaying service logs', - script: 'docker stack services --format \'{{.Name}}\' streamer4user | xargs -n 1 docker service logs' + script: "docker stack services --format '{{.Name}}' ${STACK_NAME} | xargs -n 1 docker service logs" ) } } @@ -215,7 +218,7 @@ pipeline { post { success { - archiveArtifacts "docker-compose.yml, docker-compose.swarm.yml, env.sh" + archiveArtifacts "docker-compose.yml, docker-compose.stager.yml, docker-compose.swarm.yml, env.sh" } always { echo 'cleaning' diff --git a/docker-deploy-acceptance.sh b/docker-deploy-acceptance.sh index 89d953d..e710c67 100644 --- a/docker-deploy-acceptance.sh +++ b/docker-deploy-acceptance.sh @@ -1,6 +1,8 @@ #!/bin/bash +[ $# -lt 1 ] && echo "missing Docker stack name" >&2 && exit 1 + # export variables defined in env.sh set -a && source env.sh && set +a -docker stack up -c docker-compose.yml -c docker-compose.stager.yml -c docker-compose.swarm.yml --prune --with-registry-auth --resolve-image always lab-data-streamer \ No newline at end of file +docker stack up -c docker-compose.yml -c docker-compose.stager.yml -c docker-compose.swarm.yml --prune --with-registry-auth --resolve-image always "$1" \ No newline at end of file