Skip to content

Commit

Permalink
WiP
Browse files Browse the repository at this point in the history
  • Loading branch information
mayank1211 committed Jun 14, 2024
1 parent 2424a8d commit 875e705
Showing 1 changed file with 15 additions and 31 deletions.
46 changes: 15 additions & 31 deletions build/jenkins/deployments.Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
def envProfile = ''
def options = ['NonProd': 'dev', 'Demo': 'dmo', 'Production': 'pd']

pipeline {
/*
Expand Down Expand Up @@ -26,15 +26,19 @@ pipeline {
)
}

environment {
PROFILE = options[params.PROFILE]
}

stages {
stage('Check IMAGE_TAG parameter') {
steps {
script {
def pattern = /^[0-9]{12}-[a-f0-9]{7}$/
def pattern = /^[0-9]{12}-[a-f0-9]{7}$/

if (!params.IMAGE_TAG.matches(pattern)) {
error "Provided IMAGE_TAG '${params.IMAGE_TAG}' does not match the expected pattern. Aborting build."
}
if (!params.IMAGE_TAG.matches(pattern)) {
error "Provided IMAGE_TAG '${params.IMAGE_TAG}' does not match the expected pattern. Aborting build."
}
}
}
}
Expand All @@ -48,93 +52,77 @@ pipeline {
stage('Select Environment') {
steps {
script {
def options = [
'NonProd': 'dev',
'Demo': 'dmo',
'Production': 'pd'
]
envProfile = options[params.PROFILE]
echo "Selected environment profile: ${params.PROFILE} - ${envProfile}"
echo "Selected environment profile: ${params.PROFILE} - ${env.PROFILE}"
}
}
}
stage('Pipeline Prepare') {
steps {
script {
env.PROFILE = envProfile
sh 'make pipeline-prepare'
}
}
}
stage('Show Variables') {
steps {
script {
env.PROFILE = envProfile
sh 'make devops-print-variables'
}
}
}
stage('Check Py Lib Folder') {
steps {
script {
env.PROFILE = envProfile
sh 'make create-lambda-deploy-dir'
}
}
}
stage('Plan Infrastructure') {
steps {
script {
env.PROFILE = envProfile
sh "make plan PROFILE=${envProfile}"
sh "make plan PROFILE=${env.PROFILE}"
}
}
}
stage('Infrastructure Approval') {
steps {
script {
env.PROFILE = envProfile
input 'Approve to continue with provisioning'
}
}
}
stage('Provision Infrastructure') {
steps {
script {
env.PROFILE = envProfile
sh "make provision PROFILE=${envProfile}"
sh "make provision PROFILE=${env.PROFILE}"
}
}
}
stage('Deploy API') {
steps {
script {
env.PROFILE = envProfile
sh "make deploy PROFILE=${envProfile} IMAGE_TAG=${params.IMAGE_TAG}"
sh "make deploy PROFILE=${env.PROFILE} IMAGE_TAG=${params.IMAGE_TAG}"
}
}
}
stage('Monitor Deployment') {
steps {
script {
env.PROFILE = envProfile
sh 'make k8s-check-deployment-of-replica-sets'
}
}
}
stage('Monitor Route53 Connection') {
steps {
script {
env.PROFILE = envProfile
sh 'make monitor-r53-connection'
}
}
}
stage('Perform Extract Lambda function') {
steps {
script {
env.PROFILE = envProfile
sh "make postcode-extract-etl PROFILE=${envProfile}"
sh "make postcode-extract-etl PROFILE=${env.PROFILE}"
}
}
}
Expand All @@ -146,15 +134,13 @@ pipeline {
}
steps {
script {
env.PROFILE = envProfile
sh "make postcode-insert-etl PROFILE=${envProfile}"
sh "make postcode-insert-etl PROFILE=${env.PROFILE}"
}
}
}
stage('Smoke Tests') {
steps {
script {
env.PROFILE = envProfile
sh 'make run-smoke-test'
}
}
Expand All @@ -164,14 +150,12 @@ pipeline {
failure {
script {
if (params.PROFILE == 'Demo') {
env.PROFILE = envProfile
sh 'make terraform-remove-state-lock'
}
}
}
always {
script {
env.PROFILE = envProfile
sh 'make clean'
}
}
Expand Down

0 comments on commit 875e705

Please sign in to comment.