From 8a1c4d3f189444d4b44c268842fefd4dc315bd34 Mon Sep 17 00:00:00 2001 From: Hieu Quang Date: Tue, 15 Aug 2023 00:40:25 +0700 Subject: [PATCH] Update Jenkinsfile --- Jenkinsfile | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e274f96..5ad3729 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,13 +11,25 @@ pipeline { } } } - stage('Build and push image') { + stage('Build Docker Image') { + steps { + script { + def dockerImage = 'hieuchaya4/helloworld:latest' + def dockerfilePath = '/var/jenkins_home/workspace/hello/Homework 4/Dockerfile' // Update the path accordingly + + sh "docker build -f ${dockerfilePath} -t ${dockerImage} /var/jenkins_home/workspace/hello/Homework 4" + } + } + } + + stage('Push image') { steps { withDockerRegistry(credentialsId: 'docker hub access token', url: 'https://index.docker.io/v1/') { - sh 'docker build -f ./Dockerfile -t hieuchaya4/helloworld:latest .' + //sh 'docker build -f ./Dockerfile -t hieuchaya4/helloworld:latest .' sh 'docker push hieuchaya4/helloworld:latest' } } } } } +