Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Commit

Permalink
target folder path override
Browse files Browse the repository at this point in the history
  • Loading branch information
lDucks committed Jun 25, 2019
1 parent 0baadbe commit fc4baf3
Showing 1 changed file with 34 additions and 19 deletions.
53 changes: 34 additions & 19 deletions vars/compileAndDeployMaven.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ def call(body) {
body.delegate = pipelineParams
body()

targetPath = ""
if (pipelineParams.target_path) {
targetPath = pipelineParams.target_path
}

pipeline {
agent {
docker {
Expand All @@ -26,37 +31,47 @@ def call(body) {
stage('build') {
steps {
sh 'mvn -DskipTests -U clean package'

dir(targetPath) {
sh "mvn help:effective-pom -Doutput=target/effective-pom.pom"
}
}
}
stage('deploy release') {
steps {
configFileProvider([configFile(fileId: 'artifactory-settings', variable: 'SETTINGS')]) {
sh "mvn deploy -s ${SETTINGS} -DskipTests -Dartifactory_url=https://artifactory.battleplugins.org/artifactory/"
script {
configFileProvider([configFile(fileId: 'artifactory-settings', variable: 'SETTINGS')]) {
sh "mvn deploy -s ${SETTINGS} -DskipTests -Dartifactory_url=https://artifactory.battleplugins.org/artifactory/"
}
dir(targetPath) {
pom = readMavenPom file: "target/effective-pom.pom"
archiveArtifacts artifacts: "${pom.build.directory}/${pom.build.finalName}", excludes: "original-*.jar", fingerprint: true
}
}
archiveArtifacts artifacts: 'target/*.jar', excludes: "target/original-*.jar", fingerprint: true
}
}
stage('git release') {
when { expression { BRANCH_NAME == 'master' } }
steps {
script {
sh "mvn help:effective-pom -Doutput=target/effective-pom.pom"
pom = readMavenPom file: 'target/effective-pom.pom'
withCredentials([string(credentialsId: 'github-token', variable: 'TOKEN')]) {
stdOut = sh returnStdout: true,
script: "curl -H \"Content-type: application/json\" -H \"Authorization: token ${TOKEN}\" -d '{\n" +
"\"tag_name\": \"${pom.version}\",\n" +
"\"target_commitish\": \"master\",\n" +
"\"name\": \"v${pom.version}\",\n" +
"\"draft\": false,\n" +
"\"prerelease\": false\n" +
"}' https://api.github.com/repos/BattlePlugins/${pipelineParams.repo}/releases"
dir(targetPath){
pom = readMavenPom file: "${targetPath}target/effective-pom.pom"
withCredentials([string(credentialsId: 'github-token', variable: 'TOKEN')]) {
stdOut = sh returnStdout: true,
script: "curl -H \"Content-type: application/json\" -H \"Authorization: token ${TOKEN}\" -d '{\n" +
"\"tag_name\": \"${pom.version}\",\n" +
"\"target_commitish\": \"master\",\n" +
"\"name\": \"v${pom.version}\",\n" +
"\"draft\": false,\n" +
"\"prerelease\": false\n" +
"}' https://api.github.com/repos/BattlePlugins/${pipelineParams.repo}/releases"

json = readJSON text: stdOut
if (json.upload_url) {
sh "curl -H \"Content-type: application/java-archive\" -H \"Authorization: token ${TOKEN}\" --upload-file target/${pom.build.finalName}.jar ${json.upload_url}=${pom.build.finalName}.jar"
} else {
echo "No upload_url found, is this a new release?"
json = readJSON text: stdOut
if (json.upload_url) {
sh "curl -H \"Content-type: application/java-archive\" -H \"Authorization: token ${TOKEN}\" --upload-file ${pom.build.directory}/${pom.build.finalName}.jar ${json.upload_url}=${pom.build.finalName}.jar"
} else {
echo "No upload_url found, is this a new release?"
}
}
}
}
Expand Down

0 comments on commit fc4baf3

Please sign in to comment.