From c431daa5f4e8136a5643b1aa35cae78314b3608a Mon Sep 17 00:00:00 2001 From: Jazze7 Date: Wed, 6 Nov 2024 12:42:06 +0530 Subject: [PATCH] modification v9 jenkins --- Jenkinsfile | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 566af75..113b806 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -31,18 +31,22 @@ pipeline { sh ''' ssh ${REMOTE_SERVER} "mkdir -p ${REMOTE_WORKSPACE} && cd ${REMOTE_WORKSPACE} && rm -rf cicid && git clone https://git.tech4biz.wiki/jassim/cicid.git && cd cicid && git checkout main && yarn install" ''' - } - } + } + } } } - stage('Build Docker Image') { + stage('Build Docker Image on Remote Server') { steps { script { try { - docker.build("${DOCKER_IMAGE}:${DOCKER_TAG}") + sshagent(credentials: [SSH_CREDENTIALS]) { + sh ''' + ssh ${REMOTE_SERVER} "cd ${REMOTE_WORKSPACE}/cicid && docker build -t ${DOCKER_IMAGE}:${DOCKER_TAG} ." + ''' + } } catch (Exception e) { - error "Failed to build Docker image: ${e.message}" + error "Failed to build Docker image on remote server: ${e.message}" } } } @@ -100,10 +104,5 @@ pipeline { always { cleanWs() } - // failure { - // mail to: 'jassim.mohammed@tech4biz.io', - // subject: "Pipeline Failed: ${currentBuild.fullDisplayName}", - // body: "Pipeline failed. Check the Jenkins console for more details." - // } } }