File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments