From a2c01e70c7fbf5f462f0b0bd5a4b890c9df0bd67 Mon Sep 17 00:00:00 2001 From: Jazze7 Date: Tue, 5 Nov 2024 16:45:38 +0530 Subject: [PATCH] modification in jenkins --- Jenkinsfile | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 409c8b4..a5ec583 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,19 +11,20 @@ pipeline { } stages { - // stage('Checkout') { - // steps { - // git branch: 'main', url: 'https://git.tech4biz.wiki/jassim/cicid.git' - // } - // } - stage('Checkout and Install Dependencies on Remote Server') { + stage('Checkout and Install Dependencies on Remote Server') { steps { script { sshagent(credentials: [SSH_CREDENTIALS]) { sh ''' ssh ${REMOTE_SERVER} << EOF + # Navigate to the workspace or create it if it doesn't exist + mkdir -p ${REMOTE_WORKSPACE} cd ${REMOTE_WORKSPACE} - git clone https://git.tech4biz.wiki/jassim/cicid.git . + # Clone the repository if it does not exist + if [ ! -d "cicid" ]; then + git clone https://git.tech4biz.wiki/jassim/cicid.git + fi + cd cicid git checkout main yarn install EOF @@ -57,8 +58,9 @@ pipeline { sshagent(credentials: [SSH_CREDENTIALS]) { sh ''' ssh ${REMOTE_SERVER} << EOF + cd ${REMOTE_WORKSPACE}/cicid docker pull ${DOCKER_IMAGE}:${DOCKER_TAG} - docker documentation-container || true + docker stop documentation-container || true docker rm documentation-container || true docker run -d -p 3000:3000 --name documentation-container ${DOCKER_IMAGE}:${DOCKER_TAG} EOF