Владимир Томишинец 5 năm trước cách đây
mục cha
commit
99c006b159
3 tập tin đã thay đổi với 2 bổ sung117 xóa
  1. 1 1
      Dockerfile
  2. 0 115
      Jenkinsfile
  3. 1 1
      Jenkinsfile-dev

+ 1 - 1
Dockerfile

@@ -1,5 +1,5 @@
 FROM alpine:3.10 as build
-ARG branch=newPromoSpring
+ARG branch=release
 ARG gradle_version=5.2.1
 RUN mkdir /root/.ssh
 COPY id_rsa /root/.ssh

+ 0 - 115
Jenkinsfile

@@ -1,115 +0,0 @@
-pipeline {
-  agent {
-    label "swarm"
-  }
-  environment {
-    DOCKER_REGISTRY='dev-registry.infoclinica.ru:5000'
-    DOCKER_IMAGE='promo'
-    SWARM_GIT_URL='ssh://git@git.sdsys.ru:8022/iru/stack-deploy.git'
-    SWARM_GIT_NAME='stack-deploy'
-    JENKINS_MAIL='jenkins@sdsys.ru'
-    NEWTAG=''
-  }
-  parameters {
-    string(
-      name: "GitBranch",
-      defaultValue: "newPromoSpring",
-      description: "Which branch to use"
-    )
-    string(
-      name: "service_update",
-      defaultValue: "info_promo",
-      description: "Services to update."
-    )
-    string(
-      name: "mailto",
-      defaultValue: "admin@sdsys.ru",
-      description: "Email which has to be notified."
-    )
-  }
-  stages {
-    stage("Build") {
-      steps {
-        withCredentials([sshUserPrivateKey(credentialsId: 'provision', keyFileVariable: 'GIT_SSH_KEY', passphraseVariable: '', usernameVariable: 'GIT_SSH_USERNAME')]) {
-          sh """set +x
-                cat ${GIT_SSH_KEY} > ${WORKSPACE}/id_rsa 
-                chmod 600 ${WORKSPACE}/id_rsa
-             """
-        }
-        echo "Building ${DOCKER_REGISTRY}/iru/${DOCKER_IMAGE}:${repo}-${BUILD_NUMBER}."
-        sh "docker build --build-arg branch=${GitBranch} --no-cache -t ${DOCKER_REGISTRY}/iru/${DOCKER_IMAGE}:${BUILD_NUMBER} ."
-        script {
-           NEWTAG = sh script: "docker run --rm ${DOCKER_REGISTRY}/${DOCKER_IMAGE}:${BUILD_NUMBER} cat /tmp/version 2> /dev/null", returnStdout: true
-           NEWTAG = NEWTAG + "_" + BUILD_NUMBER
-           echo "NEWTAG is $NEWTAG"
-        }
-        sh "docker tag ${DOCKER_REGISTRY}/${DOCKER_IMAGE}:${BUILD_NUMBER} ${DOCKER_REGISTRY}/${DOCKER_IMAGE}:${NEWTAG}"
-      }
-    }
-    stage("Publish") {
-      steps {
-        echo "Publishing ${DOCKER_REGISTRY}/iru/${DOCKER_IMAGE}:${NEWTAG}"
-        sh "docker push ${DOCKER_REGISTRY}/iru/${DOCKER_IMAGE}:${NEWTAG}"
-      }
-    }
-    stage("Update") {
-      when { expression { service_update != "" } }
-      steps {
-        script {
-          for (String item : service_update.split()) {
-            try{
-              echo "Updating $item"
-              sh "docker service update $item --image ${DOCKER_REGISTRY}/iru/${DOCKER_IMAGE}:${NEWTAG}"
-            }
-            catch(err){
-              echo "Recovering service $item"
-              sh "docker service rollback $item"
-              throw err
-            }
-          }
-        }
-      }
-    }
-    stage("Tagging"){
-      steps{
-        echo "Setting latest tag"
-        sh '''docker tag ${DOCKER_REGISTRY}/iru/${DOCKER_IMAGE}:${repo}-${BUILD_NUMBER} ${DOCKER_REGISTRY}/iru/${DOCKER_IMAGE}:latest
-              docker push ${DOCKER_REGISTRY}/iru/${DOCKER_IMAGE}:latest'''
-        echo "Updating tag info in ${SWARM_GIT_NAME} repository"
-        withCredentials([sshUserPrivateKey(credentialsId: 'provision', keyFileVariable: 'GIT_SSH_KEY', passphraseVariable: '', usernameVariable: 'GIT_SSH_USERNAME')]) {
-          sh '''GIT_SSH_COMMAND='ssh -i ${GIT_SSH_KEY} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' \
-                  git clone ${SWARM_GIT_URL}
-                cd ${SWARM_GIT_NAME}
-                echo -n ${NEWTAG} > tags/${DOCKER_IMAGE}.version
-                git add -A
-                git config --global user.email "${JENKINS_MAIL}"
-                git config --global user.name "Jenkins"
-                git commit -m 'Version update'
-                GIT_SSH_COMMAND='ssh -i ${GIT_SSH_KEY} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' \
-                  git push origin master
-                ls'''
-        }
-      }
-    }
-  }
-  post {
-    always {
-      echo "CleaningUp work diretory"
-      deleteDir()
-    }
-    failure {
-      mail charset: 'UTF-8',
-           subject: "Jenkins build ERROR",
-           mimeType: 'text/html',
-           to: "${mailto}",
-           body: "<b>ATTENTION!!!</b> <b><br> Jenkins job failed.\n\n <b><br>Project Name:</b> ${env.JOB_NAME} <b><br>\nBuild Number:</b> ${env.BUILD_NUMBER} <b><br>\nURL Build:</b> ${RUN_DISPLAY_URL}"
-    }
-    success {
-      mail charset: 'UTF-8',
-           subject: "Jenkins build SUSCCESS",
-           mimeType: 'text/html',
-           to: "${mailto}",
-           body: "<b>Congradulations!!!</b> <b><br> Jenkins job succefully finished.\n\n <b><br>Project Name:</b> ${env.JOB_NAME} <b><br>\nBuild Number:</b> ${env.BUILD_NUMBER} <b><br>\nURL Build:</b> ${RUN_DISPLAY_URL}"
-    }
-  }
-}

+ 1 - 1
Jenkinsfile-dev

@@ -20,7 +20,7 @@ pipeline {
   parameters {
     string(
       name: "branch",
-      defaultValue: "newPromoSpring",
+      defaultValue: "release",
       description: "Which branch to use"
     )
     string(