Skip to content

Commit f7b5a8e

Browse files
Add files via upload
1 parent dd4c48d commit f7b5a8e

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

jenkinsfile.txt

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
pipeline {
2+
agent any
3+
4+
environment {
5+
AWS_ACCOUNT_ID = "646347823701"
6+
AWS_DEFAULT_REGION = "ap-south-1"
7+
IMAGE_REPO_NAME = "jenkins-pipeline-demo"
8+
IMAGE_TAG = "latest"
9+
REPO_URL = "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${IMAGE_REPO_NAME}"
10+
}
11+
12+
stages {
13+
stage('Git Checkout') {
14+
steps {
15+
git branch: 'main', url: 'https://github.com/bhagyashree3235/java-example.git'
16+
}
17+
}
18+
19+
stage('dockerbuild') {
20+
steps {
21+
script {
22+
sh "docker build -t ${REPO_URL}:${IMAGE_TAG} ."
23+
}
24+
}
25+
}
26+
27+
stage('Logging to AWS ECR') {
28+
steps {
29+
script {
30+
sh """aws ecr get-login-password \
31+
--region ap-south-1 \
32+
| docker login \
33+
--username AWS \
34+
--password-stdin 646347823701.dkr.ecr.ap-south-1.amazonaws.com"""
35+
}
36+
}
37+
}
38+
39+
stage('ECR push') {
40+
steps {
41+
script {
42+
sh """docker push ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${IMAGE_REPO_NAME}:${IMAGE_TAG}"""
43+
}
44+
}
45+
}
46+
47+
stage('Deploy to Docker Server') {
48+
steps {
49+
script {
50+
sh "docker run -d -p 8080:8080 ${REPO_URL}:${IMAGE_TAG}"
51+
}
52+
}
53+
}
54+
}
55+
}

0 commit comments

Comments
 (0)