pipeline {
agent any
stages {
stage('Checkout from Git') {
steps {
git branch: 'main', url:
'[Link]
}
}
stage("Docker Image Build") {
steps {
script {
dir('client') {
sh 'docker system prune -f'
sh 'docker container prune -f'
sh 'docker build -t frontend .'
}
}
}
}
stage("ECR Image Pushing") {
steps {
script {
sh '''
aws ecr get-login-password --region ap-south-1 | docker login
--username AWS --password-stdin [Link]
docker tag frontend:latest [Link]-south-
[Link]/frontend:${BUILD_NUMBER}
docker push
[Link]/frontend:${BUILD_NUMBER}
'''
}
}
}
// stage('Update Deployment file') {
// environment {
// GIT_REPO_NAME = "2nd10WeeksofCloudOps-main"
// GIT_USER_NAME = "sai2612-git"
// }
// steps {
// dir('kubernetes-files') {
// withCredentials([usernamePassword(credentialsId:
'GITHUB_CREDENTIALS', usernameVariable: 'GIT_USER', passwordVariable: 'GIT_PASS')])
{
// sh '''
// git config [Link] "saiazure2612@[Link]"
// git config [Link] "sai2612-git"
// BUILD_NUMBER=${BUILD_NUMBER}
// echo $BUILD_NUMBER
// sed -i "s#image:.*#image: [Link]-
[Link]/frontend:$BUILD_NUMBER#g" [Link]
// git add .
// git commit -m "Update deployment Image to version \$
{BUILD_NUMBER}"
// git push
[Link] HEAD:main
// '''
// }
// }
// }
// }
}
}