Skip to content
This repository has been archived by the owner on Aug 13, 2022. It is now read-only.

Commit

Permalink
chore: Blue/Green Deployment Test
Browse files Browse the repository at this point in the history
  • Loading branch information
Hosick committed May 30, 2021
1 parent 1a41508 commit e69f782
Showing 1 changed file with 146 additions and 0 deletions.
146 changes: 146 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
def mainBranch = false

pipeline {
agent any
environment {
PATH = "/opt/gradle/gradle-6.3/bin:$PATH"
SLACK_CHANNEL = '#jenkins-notification'
}

stages {

stage('Git Checkout') {
steps {
checkout scm
echo 'Git Checkout Success!'
}
}

stage('Test') {
steps {
sh 'gradle test'
echo 'test success'
}

/* post {
failure {
slackSend (channel: SLACK_CHANNEL, color: '#F01717', message: "Test Failed '[${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
} */
}

stage('Build') {
steps {
sh 'gradle clean build --exclude-task test --exclude-task asciidoctor'
echo 'build success'
}

/* post {
success {
slackSend (channel: SLACK_CHANNEL, color: '#00FF00', message: "Successful testing and build '[${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
failure {
slackSend (channel: SLACK_CHANNEL, color: '#F01717', message: "Build Failed '[${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
} */
}

stage('Check Branch') {
when {
branch 'main'
}

steps {
mainBranch = true
}
}

stage('Idle Port Stop') {
when {
expression {
mainBranch
}
}

steps {
steps([$class: 'BapSshPromotionPublisherPlugin']) {
sshPublisher(
continueOnError: false, failOnError: true,
publishers: [
sshPublisherDesc(
configName: "shoe-auction-reverse-proxy",
verbose: true,
transfers: [
sshTransfer(
execCommand: "sh start.sh"
)
]
)
]
)
}
}
}

stage('Deploy To Idle Port') {
when {
expression {
mainBranch
}
}

steps([$class: 'BapSshPromotionPublisherPlugin']) {
sshPublisher(
continueOnError: false, failOnError: true,
publishers: [
sshPublisherDesc(
configName: "shoe-auction-reverse-proxy",
verbose: true,
transfers: [
sshTransfer(
execCommand: "sh health.sh"
)
]
)
]
)
}
}

stage('Check Health And Switch Ports') {
when {
expression {
mainBranch
}
}

steps([$class: 'BapSshPromotionPublisherPlugin']) {
sshPublisher(
continueOnError: false, failOnError: true,
publishers: [
sshPublisherDesc(
configName: "shoe-auction-reverse-proxy",
verbose: true,
transfers: [
sshTransfer(
execCommand: "sh stop.sh"
)
]
)
]
)
}

/* post {
success {
slackSend (channel: SLACK_CHANNEL, color: '#00FF00', message: "Health check and deployment successful '[${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
failure {
slackSend (channel: SLACK_CHANNEL, color: '#F01717', message: "Health check and deployment failure '[${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
} */
}
}
}

0 comments on commit e69f782

Please sign in to comment.