Skip to content

Commit

Permalink
Based on older Jenkins file (#110)
Browse files Browse the repository at this point in the history
Signed-off-by: Tim van Oostrom <[email protected]>
  • Loading branch information
timvanoostrom authored Jul 18, 2019
1 parent ead10fb commit 9120af2
Showing 1 changed file with 28 additions and 21 deletions.
49 changes: 28 additions & 21 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,15 @@ def tryStep(String message, Closure block, Closure tearDown = null) {


String BRANCH = "${env.BRANCH_NAME}"
String DEV_TARGET = "acceptance" // Passed as env variable to the docker containers
String DEV_TARGET = "acceptance"
String PROD_TARGET = "production"

if (BRANCH == "test") {
DEV_TARGET = "test"
}

node {
stage("Checkout") {
checkout scm
}
}

if (BRANCH != "test-acc") {
node {
if (BRANCH != "test-acc") {
stage("Test") {
tryStep "test", {
sh "docker-compose -p mijn_amsterdam_frontend -f docker-compose.yml build && " +
Expand All @@ -42,17 +36,28 @@ if (BRANCH != "test-acc") {
}
}

node {
if (BRANCH == "master" || BRANCH == "test-acc" || BRANCH == "test") {
stage("Build image (test/acc)") {
tryStep "build", {
docker.withRegistry("${DOCKER_REGISTRY}", 'docker-registry') {
def image = docker.build("mijnams/mijnamsterdam:${env.BUILD_NUMBER}", "--build-arg PROD_ENV=${DEV_TARGET} --build-arg http_proxy=${JENKINS_HTTP_PROXY_STRING} --build-arg https_proxy=${JENKINS_HTTP_PROXY_STRING} .")
image.push()
}
if (BRANCH == "test") {
DEV_TARGET = "test"
}

if (BRANCH == "master") {
stage('Waiting for approval') {
input "Deploy master to ACC?"
}
}

if (BRANCH == "master" || BRANCH == "test-acc" || BRANCH == "test") {

stage("Build image (test/acc)") {
tryStep "build", {
docker.withRegistry("${DOCKER_REGISTRY}", 'docker-registry') {
def image = docker.build("mijnams/mijnamsterdam:${env.BUILD_NUMBER}", "--build-arg PROD_ENV=${DEV_TARGET} --build-arg http_proxy=${JENKINS_HTTP_PROXY_STRING} --build-arg https_proxy=${JENKINS_HTTP_PROXY_STRING} .")
image.push()
}
}
}

node {
stage('Push image (test/acc)') {
tryStep "image tagging", {
docker.withRegistry("${DOCKER_REGISTRY}", 'docker-registry') {
Expand Down Expand Up @@ -98,14 +103,16 @@ node {
}
}

if (BRANCH == "master") {
// Enable when project is ready for production
stage('Waiting for approval') {
slackSend channel: '#ci-channel', color: 'warning', message: 'Mijn Amsterdam Frontend is waiting for Production Release - please confirm'
input "Deploy to Production?"
}
}

node {
if (BRANCH == "master") {
stage('Waiting for PRODUCTION deployment approval') {
slackSend channel: '#mijn_amsterdam', color: 'warning', message: 'Mijn Amsterdam Frontend is waiting for Production Release - please confirm'
input "Deploy to Production?"
}

stage("Build and Push Production image") {
tryStep "build", {
docker.withRegistry("${DOCKER_REGISTRY}",'docker-registry') {
Expand Down

0 comments on commit 9120af2

Please sign in to comment.