forked from sudheer76R/java-example
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJenkinsfile_ecr_eks
More file actions
65 lines (65 loc) · 2.33 KB
/
Jenkinsfile_ecr_eks
File metadata and controls
65 lines (65 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
pipeline{
agent none
environment{
IMAGE_TAG = "${BUILD_NUMBER}"
}
options {
buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '7', numToKeepStr: '10')
retry(3)
timestamps()
throttleJobProperty categories: [], limitOneJobWithMatchingParams: false, maxConcurrentPerNode: 2, maxConcurrentTotal: 2, paramsToUseForLimit: '', throttleEnabled: true, throttleOption: 'project'
}
stages{
stage('Git Checkout Stage') {
agent {label 'sonar_node'}
steps{
git branch: 'main', url: 'https://github.com/fatimatabassum05/java-example.git'
}
}
stage('SonarQube Analysis Stage') {
agent {label 'sonar_node'}
steps{
withSonarQubeEnv('sonar') {
sh "mvn clean verify sonar:sonar -Dsonar.projectKey=sonarqube_2"
}
}
}
stage('Build docker Image') {
agent {label 'docker'}
steps{
sh 'docker build -t 905418352029.dkr.ecr.ap-south-1.amazonaws.com/fatimatabassum:IMAGE_TAG .'
}
}
stage('Push to ECR'){
agent {label 'docker'}
steps{
withCredentials([aws(credentialsId: "awsCred", region: "ap-south-1")]) {
script {
sh 'aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin 905418352029.dkr.ecr.ap-south-1.amazonaws.com'
sh 'docker push 905418352029.dkr.ecr.ap-south-1.amazonaws.com/fatimatabassum:IMAGE_TAG'
}
}
}
}
stage('Deploy Stage') {
agent {label 'docker'}
steps{
withCredentials([aws(credentialsId: "awsCred", region: "ap-south-1")]) {
sh 'aws eks --region ap-south-1 update-kubeconfig --name eks-cluster'
sh 'helm upgrade --install webapp-project ./helm1 --namespace dev --create-namespace'
}
}
}
}
post {
always {
cleanWs()
}
success {
echo 'Pipeline completed successfully.'
}
failure {
echo 'Pipeline failed.'
}
}
}