Skip to content

Commit 3a0dd3d

Browse files
authored
Update jenkinsfile
1 parent f4e55e2 commit 3a0dd3d

1 file changed

Lines changed: 24 additions & 36 deletions

File tree

jenkinsfile

Lines changed: 24 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,34 @@
11
pipeline {
22
agent any
3-
environment {
3+
4+
environment {
45
registry = '276775973535.dkr.ecr.ap-south-1.amazonaws.com/docker-image-deploy'
56
}
6-
7+
78
stages {
8-
stage('Checkout') {
9+
stage('Checkout from Github') {
910
steps {
10-
git branch: 'main', url: 'https://github.com/anusha1908/java-example.git'
11+
checkout([$class: 'GitSCM', branches: [[name: '*/main']], doGenerateSubmoduleConfigurations: false, extensions: [], userRemoteConfigs: [[url: 'https://github.com/anusha1908/java-example.git']]])
1112
}
1213
}
13-
stage('Building image') {
14-
steps{
15-
script {
16-
dockerImage = docker.build registry
17-
}
18-
}
19-
}
20-
21-
stage('Pushing to ECR') {
22-
steps{
23-
script {
24-
withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: 'aws', accessKeyVariable: 'AWS_ACCESS_KEY_ID', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY']]) {
25-
sh 'aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 276775973535.dkr.ecr.ap-south-1.amazonaws.com'
26-
sh 'docker push 276775973535.dkr.ecr.ap-south-1.amazonaws.com/docker-image-deploy:latest'
27-
}
28-
}
29-
}
30-
31-
stage('Docker Run') {
32-
steps{
33-
script {
34-
sh 'docker run -d -p 8080:8080 --rm --name myContainer 276775973535.dkr.ecr.ap-south-1.amazonaws.com/docker-image-deploy:latest'
35-
}
36-
}
37-
}
38-
}
39-
40-
41-
42-
43-
4414

15+
stage('Docker Build') {
16+
steps {
17+
script {
18+
dockerImage = docker.build registry
19+
}
20+
}
21+
}
4522

46-
23+
stage('Docker Push') {
24+
steps {
25+
script {
26+
withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: 'aws']]) {
27+
sh 'aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin 276775973535.dkr.ecr.ap-south-1.amazonaws.com'
28+
sh 'docker push 276775973535.dkr.ecr.ap-south-1.amazonaws.com/docker-image-deploy:latest'
29+
}
30+
}
31+
}
32+
       }
33+
    }
34+
}

0 commit comments

Comments
 (0)