Compare commits

...

5 Commits

Author SHA1 Message Date
094cac3b92 Merge pull request 'develop' (#11) from develop into prod
Some checks reported errors
bangararaju.kottedi.in/portfolio-admin/pipeline/head Something is wrong with the build of this commit
Reviewed-on: #11
2026-03-06 07:58:07 +05:30
f33bf8cd01 fix: remove unnecessary backticks from Jenkinsfile
Some checks are pending
bangararaju.kottedi.in/portfolio-admin/pipeline/head This commit looks good
bangararaju.kottedi.in/portfolio-admin/pipeline/pr-prod Build queued...
2026-03-06 07:33:38 +05:30
85fe20d0f3 fix: remove unnecessary backticks from Jenkinsfile
Some checks failed
bangararaju.kottedi.in/portfolio-admin/pipeline/head There was a failure building this commit
2026-03-06 07:31:42 +05:30
8de5d29a4d refactor: reorganize Jenkinsfile stages and improve environment variable handling
Some checks failed
bangararaju.kottedi.in/portfolio-admin/pipeline/head There was a failure building this commit
2026-03-06 07:16:33 +05:30
17d2289974 fix: correct agent label for production environment in Jenkinsfile
All checks were successful
bangararaju.kottedi.in/admin/admin-uat/pipeline/head This commit looks good
2026-02-16 20:35:22 +05:30

183
Jenkinsfile vendored
View File

@ -1,113 +1,136 @@
pipeline { pipeline {
agent none agent none
options { options {
buildDiscarder(logRotator(numToKeepStr: '10')) buildDiscarder(logRotator(numToKeepStr: '10'))
} disableConcurrentBuilds()
}
environment { stages {
DEPLOY_PATH = getDeployPath()
ENV_FILE_ID = getEnvFileId()
TARGET_URL = getHealthUrl()
}
stages { stage('Build') {
agent { label getAgentLabel() }
stage('Checkout') { stages {
agent { label getAgentLabel() }
steps { stage('Cleanup Workspace') {
checkout scm steps {
cleanWs()
}
} }
}
stage('Inject Environment File') { stage('Checkout') {
agent { label getAgentLabel() } steps {
steps { checkout scm
configFileProvider( }
[configFile( }
fileId: ENV_FILE_ID,
targetLocation: 'src/environments/environment.ts', stage('Inject Environment File') {
replaceTokens: true steps {
)] configFileProvider(
) { [configFile(
echo "Environment file injected for ${env.BRANCH_NAME}" fileId: getEnvFileId(),
targetLocation: 'src/environments/environment.ts',
replaceTokens: true
)]
) {
echo "Injected environment for ${env.BRANCH_NAME}"
}
}
}
stage('Install & Build') {
steps {
sh '''
npm ci
ng build --configuration production --base-href /admin/
'''
} }
} }
} }
}
stage('Build Angular') { // 🚨 Production Approval Gate
agent { label getAgentLabel() } stage('Production Approval') {
steps { when {
sh ''' branch 'prod'
npm install
ng build --configuration production --base-href /admin/
'''
}
} }
steps {
stage('Deploy') { input message: "Approve deployment to PRODUCTION?", ok: "Deploy"
agent { label getAgentLabel() }
steps {
sh '''
rm -rf $DEPLOY_PATH/*
cp -r dist/portfolio-admin/browser/* $DEPLOY_PATH/
sudo /usr/bin/systemctl reload nginx
'''
}
}
stage('Health Check') {
agent { label getAgentLabel() }
steps {
sh """
sleep 2
curl -f ${TARGET_URL}
"""
}
} }
} }
post { stage('Deploy & Verify') {
failure { agent { label getAgentLabel() }
echo "Deployment failed!"
} stages {
success {
echo "Deployment successful!" stage('Deploy') {
steps {
sh """
rsync -av --delete dist/portfolio-admin/browser/ ${getDeployPath()}/
sudo /usr/bin/systemctl reload nginx
"""
}
}
stage('Health Check') {
steps {
sh """
sleep 3
curl -f ${getHealthUrl()}
"""
}
}
} }
} }
} }
post {
success {
echo "✅ Deployment successful for ${env.BRANCH_NAME}"
}
failure {
echo "❌ Deployment failed for ${env.BRANCH_NAME}"
}
}
}
//
// -------- Helper Methods -------- // -------- Helper Methods --------
//
def getAgentLabel() { def getAgentLabel() {
if (env.BRANCH_NAME == 'prod') { if (env.BRANCH_NAME == 'prod') {
return 'oracle-node' return 'oracle-prod'
} else { } else {
return 'built-in' // for develop return 'built-in'
} }
} }
def getEnvFileId() { def getEnvFileId() {
if (env.BRANCH_NAME == 'prod') { if (env.BRANCH_NAME == 'prod') {
return 'admin-prod-properties' return 'admin-prod-properties'
} else { } else {
return 'admin-uat-properties' return 'admin-uat-properties'
} }
} }
def getDeployPath() { def getDeployPath() {
if (env.BRANCH_NAME == 'prod') { if (env.BRANCH_NAME == 'prod') {
return "/var/www/bangararaju.kottedi.in/admin" return "/var/www/bangararaju.kottedi.in/admin"
} else { } else {
return "/var/www/bangararaju.kottedi.in/admin" return "/var/www/bangararaju.kottedi.in/admin"
} }
} }
def getHealthUrl() { def getHealthUrl() {
if (env.BRANCH_NAME == 'prod') { if (env.BRANCH_NAME == 'prod') {
return "https://bangararaju.kottedi.in/admin" return "https://bangararaju.kottedi.in/admin"
} else { } else {
return "https://bangararaju-uat.kottedi.in/admin" return "https://bangararaju-uat.kottedi.in/admin"
} }
} }