forked from open744/terramaster
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Jenkinsfile
91 lines (87 loc) · 3.7 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
pipeline {
agent any
environment{
def files = findFiles(glob: '**/terramaster.jar')[0].getPath()
}
stages {
stage('version') {
steps{
script{
if (env.BRANCH_NAME == 'master') {
script {
def props = readProperties file: 'target/maven-archiver/pom.properties'
def message = props['version']
//Pipe through tee to get rid of errorlevel
withEnv(["SID=${env.sid}"]) {
result = bat(returnStdout:true, script: "C:\\Users\\keith.paterson\\go\\bin\\github-release info -s %SID% -u Portree-Kid -r terramaster -t ${message} 2>&1 | tee").trim()
}
if( props.size() == 0 || result.trim().indexOf("could not find the release corresponding") > 0 ) {
withEnv(["JAVA_HOME=${ tool 'jdk1.8.0_121' }"]) {
try {
withMaven(maven: 'Maven 3.5.3') {
bat "mvn release:prepare -Dresume=false"
}
def releaseProps = readProperties file: 'release.properties'
} catch (error) {
withMaven(maven: 'Maven 3.5.3') {
bat "mvn release:rollback"
}
error("Release-Prepare failed")
}
}
}
}
}
}
}
}
stage( 'build' ) {
steps{
script {
if (env.BRANCH_NAME != 'master') {
withEnv(["JAVA_HOME=${ tool 'jdk1.8.0_121' }"]) {
withMaven(maven: 'Maven 3.5.3') {
bat "mvn clean install"
}
}
archiveArtifacts '*terramaster*.jar'
}
}
}
}
stage( 'deploy' ) {
steps{
script{
echo env.BRANCH_NAME
if (env.BRANCH_NAME == 'master') {
def props = readProperties file: 'target/maven-archiver/pom.properties'
def releaseProps = readProperties file: 'release.properties'
def version = props['version']
def tag = releaseProps[ 'scm.tag' ]
echo "Releasing ${version} Tag : ${tag}"
withEnv(["JAVA_HOME=${ tool 'jdk1.8.0_121' }"]) {
withMaven(maven: 'Maven 3.5.3') {
bat "mvn release:perform"
}
}
//Pipe through tee to get rid of errorlevel
withEnv(["SID=${env.sid}"]) {
result = bat(returnStdout:true, script: "C:\\Users\\keith.paterson\\go\\bin\\github-release info -s %SID% -u Portree-Kid -r terramaster -t ${tag} 2>&1 | tee").trim()
echo "${result} " + result.trim().indexOf("could not find the release corresponding")
if( result.trim().indexOf("could not find the release corresponding") > 0 ) {
bat "C:\\Users\\keith.paterson\\go\\bin\\github-release release -s %SID% -u Portree-Kid -r terramaster -t ${tag}"
}
bat """C:\\Users\\keith.paterson\\go\\bin\\github-release upload -s %SID% -u Portree-Kid -r terramaster -t ${tag} -l ${tag}.jar -n ${tag}.jar -f target/${tag}.jar"""
}
}
archiveArtifacts '*terramaster*.jar'
}
}
}
}
post {
always {
junit 'target/surefire-reports/*.xml'
}
}
}