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
'''
}
}
}
}