美文网首页
jenkins pipeline nexus结合

jenkins pipeline nexus结合

作者: _fishman | 来源:发表于2019-11-13 18:22 被阅读0次

java项目把构建产物推送到nexus

pipeline {
    agent any

    environment {
       PRODUCT = "upp"
    }

    tools {
       maven 'Default'
    }

    parameters {
        gitParameter branchFilter: 'origin/(.*)', defaultValue: 'master', name: 'git_branch', type: 'PT_BRANCH'
        choice choices: ['test', 'uat'], description: '', name: 'profile'
    }

    stages {
        stage('Clone') {
            steps {
                git branch: "${params.git_branch}", url: 'ssh://git@10.26.10.76:2212/pay/upp.git'
            }
        }

        stage('Build') {
            steps {
                echo "${params.profile}"
                sh 'mvn clean install -P ${profile} -Dmaven.test.skip=true'           
            }
        }

        stage('Artifacts') {
            steps {
                archiveArtifacts '**/*.zip,**/*.war'
            }
        }
        stage('Push') {
            steps {
                sh '''
                #!/bin/sh
                pkgDir="${JENKINS_HOME}/jobs/${JOB_NAME}/builds/${BUILD_NUMBER}/archive"
                findRes=`find ${pkgDir} -type f -iname '*.zip' -o -type f -iname '*.war'`
                for i in $findRes ;do 
                curl -v -u user:password --upload-file $i http://maven.test.com:8081/repository/pkg/${PRODUCT}/${profile}/${BUILD_NUMBER}/;
                done
                '''
            }
        }
    }
}

相关文章

网友评论

      本文标题:jenkins pipeline nexus结合

      本文链接:https://www.haomeiwen.com/subject/dbjkictx.html