pipeline拉取代码构建上传制品

pipeline {
    agent {
    label 'ubuntu'
  }
  stages {
      stage('拉取代码') {
        steps {
        checkout scmGit(branches: [[name: 'main']],
        extensions: [submodule(depth: 1, parentCredentials: true, recursiveSubmodules: true, reference: '', shallow: true), lfs()],
        userRemoteConfigs: [[credentialsId: 'gitlab-http', url: 'http://gitlab-soa/gitlab-instance-ad96d090/test_demo']])

      }
    }

      stage('maven构建') {
        steps {
          script {
          sh '''set +x
          mvn clean package -Dmaven.test.skip=true -U
          '''
          }

        }
      }

    stage('制品上传') {
        steps {
          script {
            if (!fileExists('target/demo-0.0.1-SNAPSHOT.jar')) {error 'target/demo-0.0.1-SNAPSHOT.jar no exist'}
          }

          script {
            sh '''set +x
            mc config host add minio http://192.26.193.11:32657 admin 123456
            mc mb minio/537b1da2-f3ba-4e20-a646-b49f4ac31ad8-11-14
            mc cp target/demo-0.0.1-SNAPSHOT.jar minio/537b1da2-f3ba-4e20-a646-b49f4ac31ad8-11-14
            #DEPEND_SWTICH# '''
          }

        }
    }

  }
  post {
    always {
      cleanWs()
    }

  }
  options {
  timeout(time: 1200, unit: 'MINUTES')
  }
}

 

posted @ 2024-03-19 14:31  KeepSmiling_me  阅读(32)  评论(0)    收藏  举报