jenkins持续集成jenkinsfile

 

node {
    stage("clean") {
        cleanWs()
    }
    def mvnHome = env.MAVEN_HOME
    stage('Preparation') {
        checkout([$class                           : 'GitSCM',
                  branches                         : [[name: "*/${env.GIT_BRANCH}"]],
                  doGenerateSubmoduleConfigurations: false, extensions: [],
                  submoduleCfg                     : [],
                  userRemoteConfigs                : [[credentialsId: 'db7c9c34-97d4-4a90-916d-6cb9a53b2a17', url: 'git@192.168.31.130:xx/xx.git']]
        ])
    }
    if (env.IS_MODIFY_VERSION == "true") {
        stage('modify_version') {
            sh "mvn versions:set -DoldVersion=* -DnewVersion=${XX_VERSION} -DprocessAllModules=true -DallowSnapshots=true"
        }
        stage("version_commit") {
            if ("$GIT_BRANCH" != "null") {
                sh """
            git status
            git config --global user.name "wangzhu"
            git config --global user.email "wangzhu@xx.com"
            git add -u
            git commit -m "modify_version"
            git push origin HEAD:refs/heads/$GIT_BRANCH
            """
            }
        }
        stage("deploy") {
            sh "mvn clean deploy -Dmaven.test.skip=ture"
        }
    }
    stage('Build') {
        if (isUnix()) {
            sh "'${mvnHome}/bin/mvn' -Dmaven.test.skip=ture -Dmaven.test.failure.ignore clean package "
        } else {
            bat(/"${mvnHome}\bin\mvn" -Dmaven.test.skip=ture -Dmaven.test.failure.ignore clean package /)
        }
    }
    stage('docker_build') {
        parallel auth: {
            sh 'docker build --build-arg APOLLO_ENV=${APOLLO_ENV} --build-arg APOLLO_META=${APOLLO_META} --build-arg xx_VERSION=${xx_VERSION} -t 192.168.31.201:5000/xx-auth-server ./xx-auth-server'
            sh 'docker push 192.168.31.201:5000/xx-auth-server'
        }, zuul: {
            sh 'docker build --build-arg APOLLO_ENV=${APOLLO_ENV} --build-arg APOLLO_META=${APOLLO_META} --build-arg xx_VERSION=${xx_VERSION} -t 192.168.31.201:5000/xx-zuul-server ./xx-zuul-server'
            sh 'docker push 192.168.31.201:5000/xx-zuul-server'
        }
    }
    stage("docker_run") {
        sh """
           docker-compose down 
           docker-compose up -d
           """
    }
    stage('Results') {
        junit '**/target/surefire-reports/TEST-*.xml'
    }
}

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值