Compare commits
11 Commits
jenkins-ba
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
| 17d2289974 | |||
| a0e56f6a89 | |||
| 8885e288ed | |||
| a888636487 | |||
| dad46d788d | |||
| 3619e33f44 | |||
| cf8e3b880c | |||
| a6e48d6b2b | |||
| 06a64fa018 | |||
| 1bec713692 | |||
| cea6d218f8 |
113
Jenkinsfile
vendored
Normal file
113
Jenkinsfile
vendored
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
pipeline {
|
||||||
|
|
||||||
|
agent none
|
||||||
|
|
||||||
|
options {
|
||||||
|
buildDiscarder(logRotator(numToKeepStr: '10'))
|
||||||
|
}
|
||||||
|
|
||||||
|
environment {
|
||||||
|
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: ENV_FILE_ID,
|
||||||
|
targetLocation: 'src/environments/environment.ts',
|
||||||
|
replaceTokens: true
|
||||||
|
)]
|
||||||
|
) {
|
||||||
|
echo "Environment file injected for ${env.BRANCH_NAME}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Build Angular') {
|
||||||
|
agent { label getAgentLabel() }
|
||||||
|
steps {
|
||||||
|
sh '''
|
||||||
|
npm install
|
||||||
|
ng build --configuration production --base-href /admin/
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('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 {
|
||||||
|
failure {
|
||||||
|
echo "Deployment failed!"
|
||||||
|
}
|
||||||
|
success {
|
||||||
|
echo "Deployment successful!"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------- Helper Methods --------
|
||||||
|
|
||||||
|
def getAgentLabel() {
|
||||||
|
if (env.BRANCH_NAME == 'prod') {
|
||||||
|
return 'oracle-prod'
|
||||||
|
} 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"
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user