kubespere 流水线

/ 测试开发 / 0 条评论 / 860浏览
pipeline {
  agent {
    node {
      label 'maven'
    }

  }
  stages {
    stage('代码拉取') {
      agent none
      steps {
        git(url: '${GIT_URL}', credentialsId: 'git-pw', branch: '${GIT_BRANCH}', changelog: true, poll: false)
      }
    }

    stage('构建并推送镜像') {
      agent none
      steps {
        container('maven') {
          sh 'mvn  clean install -Dmaven.test.skip=true -am'
          sh 'docker build -f Dockerfile -t $REGISTRY/wyyt/ms/jacoco_platfrom:$IMAGE_TAG-$BUILD_NUMBER .'
          withCredentials([usernamePassword(credentialsId : 'dockerhub-pw' ,passwordVariable : 'DOCKER_PASSWORD' ,usernameVariable : 'DOCKER_USERNAME' ,)]) {
            sh 'echo "$DOCKER_PASSWORD" | docker login $REGISTRY -u "$DOCKER_USERNAME" -p xxx '
            sh 'docker push $REGISTRY/wyyt/ms/jacoco_platfrom:$IMAGE_TAG-$BUILD_NUMBER'
          }

        }

      }
    }

  }
  environment {
    DEPLOYMENT_GIT_URL = 'http://git.sijibao.com/testgroup/jacoco.git'
    DEPLOYMENT_GIT_BRANCHE = 'master'
  }
}