Skip to content

Commit

Permalink
SFD-5941 Unify Deployment Pipelines and Improve Stage Visibility and …
Browse files Browse the repository at this point in the history
…Debugging (#299)

Combining Deployment Pipelines:
- Unified the deployment pipelines for non-prod, demo, and prod environments into a single instance.
Manual Approval Step:
- Added a manual approval stage before the provisioning step.
  • Loading branch information
mayank1211 authored Jun 19, 2024
1 parent 8906fa2 commit 52ad239
Show file tree
Hide file tree
Showing 2 changed files with 176 additions and 128 deletions.
176 changes: 176 additions & 0 deletions build/jenkins/deployments.Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
def envProfile = ''

pipeline {
/*
Description: Unified pipeline to deploy to various environments
*/
agent any

options {
buildDiscarder(logRotator(daysToKeepStr: '7', numToKeepStr: '13'))
disableConcurrentBuilds()
parallelsAlwaysFailFast()
timeout(time: 30, unit: 'MINUTES')
}

parameters {
string(
description: 'Enter image tag to deploy, e.g. 202103111417-e362c87',
name: 'IMAGE_TAG',
defaultValue: ''
)
choice(
name: 'PROFILE',
choices: ['NonProd', 'Demo', 'Production'],
description: 'Select environment profile'
)
}

stages {
stage('Check IMAGE_TAG parameter') {
steps {
script {
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."
}
}
}
}
stage('Prepare for jenkins-slave run') {
steps {
script {
sh 'make pipeline-slave-prepare'
}
}
}
stage('Select Environment') {
steps {
script {
def options = [
'NonProd': 'dev',
'Demo': 'dmo',
'Production': 'pd'
]
envProfile = options[params.PROFILE]
echo "Selected environment profile: ${params.PROFILE} - ${envProfile}"
}
}
}
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}"
}
}
}
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}"
}
}
}
stage('Deploy API') {
steps {
script {
env.PROFILE = envProfile
sh "make deploy PROFILE=${envProfile} 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}"
}
}
}
stage('Perform Insert Lambda function') {
when {
expression {
params.PROFILE != 'dev'
}
}
steps {
script {
env.PROFILE = envProfile
sh "make postcode-insert-etl PROFILE=${envProfile}"
}
}
}
stage('Smoke Tests') {
steps {
script {
env.PROFILE = envProfile
sh 'make run-smoke-test'
}
}
}
}
post {
failure {
script {
sh 'make terraform-remove-state-lock'
}
}
always {
script {
env.PROFILE = envProfile
sh 'make clean'
}
}
}
}
128 changes: 0 additions & 128 deletions build/jenkins/dev/Dev_Deployment.Jenkinsfile

This file was deleted.

0 comments on commit 52ad239

Please sign in to comment.