我想创建 jenkins 声明性管道,以便使用 maven 命令在 xl-deploy 上进行部署。我没有使用 xl-deploy 插件,我只是为此使用 maven 命令。
pipeline {
agent {
label 'java8'
}
tools {
maven 'M3'
}
options {
skipDefaultCheckout()
timestamps()
disableConcurrentBuilds()
timeout(time: 1, unit: 'HOURS')
buildDiscarder(logRotator(numToKeepStr: "${env.BRANCH_NAME}"=='master'?'10':''))
}
environment {
ARTIFACTORY = credentials('artifactory-credentials')
CF = credentials('cf-credentials')
SONAR = credentials('Sonar_Credentials')
}
stages {
stage ('Checkout') {
steps {
checkout scm
sh "git rev-parse HEAD > .git/commit-id"
script {
commit_id = readFile('.git/commit-id').trim()
pom = readMavenPom file: 'pom.xml'
currentBuild.displayName = commit_id.take(7) + "-" + pom.version
}
}
}
stage ('Build') {
steps {
sh "mvn -U -s settings.xml -gs settings.xml clean install -DskipTests=true"
}
}
stage('Publish Artifacts') {
when {
branch 'master'
}
steps {
sh "echo 'Publish JAR to Artifactory !'"
sh "mvn -s settings.xml -gs settings.xml versions:set -DnewVersion=$commit_id"
sh "mvn -s settings.xml -gs settings.xml deploy -DskipTests=true"
}
}
stage('Deploy') {
steps {
sh "wget --user ${ARTIFACTORY_USR} --password ${ARTIFACTORY_PSW} -O ${pom.artifactId}.war -nv <repo url>/${pom.artifactId}/${commit_id}/${pom.artifactId}-${commit_id}.war --server-response --"
sh "mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:copy -Dartifact=<app package>-$commit_id:war -DoutputDirectory=target -Dmdep.useBaseVersion=true"
}}
}
post {
always {
deleteDir()
}
}
}
我收到以下异常:
未能执行目标 com.xebialabs.xldeploy:xldeploy-maven-plugin:5.0.2:generate-deployment-package。
直到发布,它工作正常。但在执行部署阶段时出现异常