From 863cc9a8abd1ac012120a46726e5c91c486a3fe2 Mon Sep 17 00:00:00 2001 From: bhargav867 <126657766+bhargav867@users.noreply.github.com> Date: Wed, 11 Jun 2025 10:57:39 -0500 Subject: [PATCH 1/5] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6251b1a..fe5b895 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { steps { script { withDockerRegistry(credentialsId: 'dockerhub') { - sh 'docker push shaikmustafa/paytm:movie' + sh 'docker push msvbhargav99/paytm:movie' } } } From 3db623ad7d850045ce73d0ff037fae6f105af7d7 Mon Sep 17 00:00:00 2001 From: bhargav867 <126657766+bhargav867@users.noreply.github.com> Date: Wed, 11 Jun 2025 13:25:16 -0500 Subject: [PATCH 2/5] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index fe5b895..17e1865 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,7 +9,7 @@ pipeline { } stage ("Tag") { steps { - sh 'docker tag image3 shaikmustafa/paytm:movie' + sh 'docker tag image3 msvbhargav99/paytm:movie' } } stage ("Push") { From 0249c535cb67b82e4897f9200979b214aa2111f1 Mon Sep 17 00:00:00 2001 From: bhargav867 <126657766+bhargav867@users.noreply.github.com> Date: Wed, 11 Jun 2025 13:25:44 -0500 Subject: [PATCH 3/5] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 17e1865..6e10626 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -23,7 +23,7 @@ pipeline { } stage ("Deploy") { steps { - sh 'docker run -itd --name movie-app -p 3333:80 shaikmustafa/paytm:movie' + sh 'docker run -itd --name movie-app -p 3333:80 msvbhargav99/paytm:movie' } } } From acc101e5dd3baca9c70c6d40b69335a367ec1ce1 Mon Sep 17 00:00:00 2001 From: bhargav867 <126657766+bhargav867@users.noreply.github.com> Date: Wed, 11 Jun 2025 13:37:45 -0500 Subject: [PATCH 4/5] Update Jenkinsfile --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6e10626..d2348fa 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,21 +9,21 @@ pipeline { } stage ("Tag") { steps { - sh 'docker tag image3 msvbhargav99/paytm:movie' + sh 'docker tag image3 msvbhargav99/paytm:movie1' } } stage ("Push") { steps { script { withDockerRegistry(credentialsId: 'dockerhub') { - sh 'docker push msvbhargav99/paytm:movie' + sh 'docker push msvbhargav99/paytm:movie1' } } } } stage ("Deploy") { steps { - sh 'docker run -itd --name movie-app -p 3333:80 msvbhargav99/paytm:movie' + sh 'docker run -itd --name movie-app -p 3333:80 msvbhargav99/paytm:movie1' } } } From 926653152e59eba15a333498bc58b72f4d7cba3d Mon Sep 17 00:00:00 2001 From: bhargav867 <126657766+bhargav867@users.noreply.github.com> Date: Wed, 11 Jun 2025 13:40:15 -0500 Subject: [PATCH 5/5] Update Jenkinsfile --- Jenkinsfile | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d2348fa..6a93765 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,23 +7,34 @@ pipeline { sh 'docker build -t image3 .' } } - stage ("Tag") { + + stage('Tag') { steps { - sh 'docker tag image3 msvbhargav99/paytm:movie1' + // Use the branch name as the Docker tag + sh "docker tag image3 msvbhargav99/paytm:${env.BRANCH_NAME}" } } - stage ("Push") { + + stage('Push') { steps { script { withDockerRegistry(credentialsId: 'dockerhub') { - sh 'docker push msvbhargav99/paytm:movie1' + sh "docker push msvbhargav99/paytm:${env.BRANCH_NAME}" } } } } - stage ("Deploy") { + + stage('Deploy') { steps { - sh 'docker run -itd --name movie-app -p 3333:80 msvbhargav99/paytm:movie1' + // 1) Remove any existing container named 'movie-app' + // 2) Start a fresh one, using the branch name as image tag + sh ''' + if docker ps -a --format '{{.Names}}' | grep -q '^movie-app$'; then + docker rm -f movie-app + fi + ''' + sh "docker run -d --name movie-app -p 3333:80 msvbhargav99/paytm:${env.BRANCH_NAME}" } } }