Compare commits

..

No commits in common. "3be0d38cf1bd08a42ae37c3ffcafc8642b788190" and "7cf7246abd2aeccab49084d9977af5ce55646c06" have entirely different histories.

62
Jenkinsfile vendored
View File

@ -1,43 +1,35 @@
pipeline { pipeline {
agent { label 'built-in' }
agent none
options { options {
buildDiscarder(logRotator(numToKeepStr: '10')) buildDiscarder(logRotator(numToKeepStr: '10'))
} }
environment { environment {
DEPLOY_PATH = getDeployPath() DEPLOY_PATH = "/var/www/bangararaju.kottedi.in/admin"
ENV_FILE_ID = getEnvFileId()
TARGET_URL = getHealthUrl()
} }
stages { stages {
stage('Checkout') { stage('Checkout') {
agent { label getAgentLabel() }
steps { steps {
checkout scm checkout scm
} }
} }
stage('Inject Environment File') { stage('Inject Environment File') {
agent { label getAgentLabel() }
steps { steps {
configFileProvider( configFileProvider(
[configFile( [configFile(fileId: 'admin-uat-properties',
fileId: ENV_FILE_ID, targetLocation: 'src/environments/environment.ts',
targetLocation: 'src/environments/environment.ts', replaceTokens: true)]
replaceTokens: true
)]
) { ) {
echo "Environment file injected for ${env.BRANCH_NAME}" echo "Environment file injected"
} }
} }
} }
stage('Build Angular') { stage('Build Angular') {
agent { label getAgentLabel() }
steps { steps {
sh ''' sh '''
npm install npm install
@ -47,7 +39,6 @@ pipeline {
} }
stage('Deploy') { stage('Deploy') {
agent { label getAgentLabel() }
steps { steps {
sh ''' sh '''
rm -rf $DEPLOY_PATH/* rm -rf $DEPLOY_PATH/*
@ -58,12 +49,11 @@ pipeline {
} }
stage('Health Check') { stage('Health Check') {
agent { label getAgentLabel() }
steps { steps {
sh """ sh '''
sleep 2 sleep 2
curl -f ${TARGET_URL} curl -f https://bangararaju-uat.kottedi.in/admin
""" '''
} }
} }
} }
@ -77,37 +67,3 @@ pipeline {
} }
} }
} }
// -------- Helper Methods --------
def getAgentLabel() {
if (env.BRANCH_NAME == 'prod') {
return 'oracle-node'
} else {
return 'built-in' // for develop
}
}
def getEnvFileId() {
if (env.BRANCH_NAME == 'prod') {
return 'admin-prod-properties'
} else {
return 'admin-uat-properties'
}
}
def getDeployPath() {
if (env.BRANCH_NAME == 'prod') {
return "/var/www/bangararaju.kottedi.in/admin"
} else {
return "/var/www/bangararaju.kottedi.in/admin"
}
}
def getHealthUrl() {
if (env.BRANCH_NAME == 'prod') {
return "https://bangararaju.kottedi.in/admin"
} else {
return "https://bangararaju-uat.kottedi.in/admin"
}
}