Skip to content
pipeline {
  agent any
  stages {
    stage('检出') {
      steps {
        checkout([$class: 'GitSCM', branches: [[name: env.GIT_BUILD_REF]], 
                                                                    userRemoteConfigs: [[url: env.GIT_REPO_URL, credentialsId: env.CREDENTIALS_ID]]])
      }
    }
    stage('构建') {
      steps {
        echo '构建中...'
        sh 'docker version'
        sh 'mvn package -Dmaven.test.skip=true'
        echo '构建完成.'
      }
    }
    stage('测试') {
      steps {
        echo '单元测试中...'
        echo '单元测试完成.'
      }
    }
    stage('部署') {
      steps {
        echo '部署中...'
        sh 'sshpass -p "Aa.17770060561" scp -r /root/workspace/target/blog-0.0.1-SNAPSHOT.jar root@39.108.61.221:/usr/local/docker/newblog/env'
        echo '部署完成'
      }
    }
  }
}

ssh root@39.108.61.221 "cd /usr/local/docker/newblog ; docker-compose up"

文章来源于自己总结和网络转载,内容如有任何问题,请大佬斧正!联系我