From d78dbb75c9ce41b220e63bc9c5548748c9e3fe5b Mon Sep 17 00:00:00 2001 From: ashoktg012 <126315601+ashoktg012@users.noreply.github.com> Date: Wed, 11 Oct 2023 22:08:23 +0530 Subject: [PATCH 1/3] Create Jenkinsfile --- Jenkinsfile | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..d565ff18 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,33 @@ +pipeline { + agent any + + stages { + stage('Checkout') { + steps { + // Checkout code from the GitHub repository + git url: 'https://github.com/ashoktg012/SaiJavaCode.git', branch: 'master' + } + } + + stage('Build docker image') { + steps { + script { + def registry = 'docker.io' // Docker Hub registry + def customImageName = 'ashoktg012/firstimage1:latest' + + // Build the Docker image + sh "docker build -t $customImageName -f Dockerfile ." + + // Push the Docker image to Docker Hub + withCredentials([usernamePassword(credentialsId: 'ashokdockerhub', usernameVariable: 'DOCKERHUB_USERNAME', passwordVariable: 'DOCKERHUB_PASSWORD')]) { + sh "docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD" + sh "docker push $customImageName" + } + } + } + + } + // Add more stages as needed + } +} + From f0b685efee7d303b58966c1ae7afa32df9abe96d Mon Sep 17 00:00:00 2001 From: ashoktg012 <126315601+ashoktg012@users.noreply.github.com> Date: Wed, 11 Oct 2023 22:11:59 +0530 Subject: [PATCH 2/3] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index d565ff18..88febcc9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { def customImageName = 'ashoktg012/firstimage1:latest' // Build the Docker image - sh "docker build -t $customImageName -f Dockerfile ." + docker.build(customImageName, "-f Dockerfile .") // Push the Docker image to Docker Hub withCredentials([usernamePassword(credentialsId: 'ashokdockerhub', usernameVariable: 'DOCKERHUB_USERNAME', passwordVariable: 'DOCKERHUB_PASSWORD')]) { From 466473a90cce27efcc44e7ca9ec5d2a5f5665873 Mon Sep 17 00:00:00 2001 From: ashoktg012 <126315601+ashoktg012@users.noreply.github.com> Date: Wed, 11 Oct 2023 22:16:07 +0530 Subject: [PATCH 3/3] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 88febcc9..d565ff18 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { def customImageName = 'ashoktg012/firstimage1:latest' // Build the Docker image - docker.build(customImageName, "-f Dockerfile .") + sh "docker build -t $customImageName -f Dockerfile ." // Push the Docker image to Docker Hub withCredentials([usernamePassword(credentialsId: 'ashokdockerhub', usernameVariable: 'DOCKERHUB_USERNAME', passwordVariable: 'DOCKERHUB_PASSWORD')]) {