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