Compare commits

..

2 Commits

Author SHA1 Message Date
3be0d38cf1 Merge pull request 'refactor: streamline Jenkinsfile by using helper methods for environment variables and agent labels' (#10) from develop into prod
Some checks reported errors
bangararaju.kottedi.in/admin/admin-prod/pipeline/head Build queued...
bangararaju.kottedi.in/portfolio-admin/pipeline/head Something is wrong with the build of this commit
Reviewed-on: #10
2026-02-16 20:33:10 +05:30
a0e56f6a89 refactor: streamline Jenkinsfile by using helper methods for environment variables and agent labels
All checks were successful
bangararaju.kottedi.in/admin/admin-prod/pipeline/head This commit looks good
bangararaju.kottedi.in/admin/admin-uat/pipeline/head This commit looks good
2026-02-16 20:28:02 +05:30

62
Jenkinsfile vendored
View File

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