This repository has been archived by the owner on Sep 6, 2023. It is now read-only.
forked from MysticCity/MinigamesAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
61 lines (56 loc) · 1.83 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
pipeline {
agent any
tools {
maven 'maven3.5.0'
jdk 'jdk8'
}
stages {
stage ('Initialization') {
steps {
echo 'Preparing for build'
}
}
stage ('Build') {
steps {
sh 'mvn clean install'
archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true
}
post {
failure {
mail to: '[email protected]', subject: 'build of MinigamesLib failed', body: 'build of MinigamesLib failed'
}
}
}
stage ('Upload') {
steps {
script {
env.BUILDTYPE = readPomVersion().endsWith("-SNAPSHOT") ? "snapshots" : "releases";
}
sh "/srv/hudson/upload_product.sh ${env.BUILDTYPE} API/target 1 minigameslib MinigamesLib"
}
}
stage ('Deploy') {
when {
expression {
currentBuild.result == null || currentBuild.result == 'SUCCESS'
}
}
steps {
sh 'mvn -Dmce.deployment=true -Dmaven.test.skip=true -DskipTests deploy'
}
post {
failure {
mail to: '[email protected]', subject: 'deploy of MinigamesLib failed', body: 'deploy of MinigamesLib failed'
}
}
}
}
}
def readPomVersion() {
// Reference: http://stackoverflow.com/a/26514030/1851299
sh "mvn --quiet --non-recursive -Dexec.executable='echo' -Dexec.args='\${project.version}' org.codehaus.mojo:exec-maven-plugin:1.3.1:exec > pom.project.version.txt"
pomProjectVersion = readFile('pom.project.version.txt').trim()
sh "rm -f pom.project.version.txt"
echo "Current POM version: ${pomProjectVersion}"
return pomProjectVersion
}