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
This commit is contained in:
rajukottedi 2026-03-06 07:58:07 +05:30
commit 094cac3b92

77
Jenkinsfile vendored
View File

@ -4,87 +4,110 @@ pipeline {
options { options {
buildDiscarder(logRotator(numToKeepStr: '10')) buildDiscarder(logRotator(numToKeepStr: '10'))
} disableConcurrentBuilds()
environment {
DEPLOY_PATH = getDeployPath()
ENV_FILE_ID = getEnvFileId()
TARGET_URL = getHealthUrl()
} }
stages { stages {
stage('Checkout') { stage('Build') {
agent { label getAgentLabel() } agent { label getAgentLabel() }
stages {
stage('Cleanup Workspace') {
steps {
cleanWs()
}
}
stage('Checkout') {
steps { steps {
checkout scm checkout scm
} }
} }
stage('Inject Environment File') { stage('Inject Environment File') {
agent { label getAgentLabel() }
steps { steps {
configFileProvider( configFileProvider(
[configFile( [configFile(
fileId: ENV_FILE_ID, fileId: getEnvFileId(),
targetLocation: 'src/environments/environment.ts', targetLocation: 'src/environments/environment.ts',
replaceTokens: true replaceTokens: true
)] )]
) { ) {
echo "Environment file injected for ${env.BRANCH_NAME}" echo "Injected environment for ${env.BRANCH_NAME}"
} }
} }
} }
stage('Build Angular') { stage('Install & Build') {
agent { label getAgentLabel() }
steps { steps {
sh ''' sh '''
npm install npm ci
ng build --configuration production --base-href /admin/ ng build --configuration production --base-href /admin/
''' '''
} }
} }
}
}
// 🚨 Production Approval Gate
stage('Production Approval') {
when {
branch 'prod'
}
steps {
input message: "Approve deployment to PRODUCTION?", ok: "Deploy"
}
}
stage('Deploy & Verify') {
agent { label getAgentLabel() }
stages {
stage('Deploy') { stage('Deploy') {
agent { label getAgentLabel() }
steps { steps {
sh ''' sh """
rm -rf $DEPLOY_PATH/* rsync -av --delete dist/portfolio-admin/browser/ ${getDeployPath()}/
cp -r dist/portfolio-admin/browser/* $DEPLOY_PATH/
sudo /usr/bin/systemctl reload nginx sudo /usr/bin/systemctl reload nginx
''' """
} }
} }
stage('Health Check') { stage('Health Check') {
agent { label getAgentLabel() }
steps { steps {
sh """ sh """
sleep 2 sleep 3
curl -f ${TARGET_URL} curl -f ${getHealthUrl()}
""" """
} }
} }
}
}
} }
post { post {
failure {
echo "Deployment failed!"
}
success { success {
echo "Deployment successful!" 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'
} }
} }