This repository was archived by the owner on Nov 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathJenkinsfile
More file actions
130 lines (106 loc) · 4.15 KB
/
Jenkinsfile
File metadata and controls
130 lines (106 loc) · 4.15 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
pipeline {
agent any
tools {
jdk "1.8.0_222"
}
options {
buildDiscarder logRotator(numToKeepStr: '10')
}
environment {
PROJECT_VERSION = getProjectVersion().replace("-SNAPSHOT", "");
IS_SNAPSHOT = getProjectVersion().endsWith("-SNAPSHOT");
}
stages {
stage('Update snapshot version') {
when {
allOf {
environment name:'IS_SNAPSHOT', value: 'true'
}
}
steps {
sh 'mvn versions:set -DnewVersion="${PROJECT_VERSION}.${BUILD_NUMBER}-SNAPSHOT"';
}
}
stage('Clean') {
steps {
sh 'mvn clean';
}
}
stage('Build') {
steps {
sh 'mvn package';
}
}
stage('Verify') {
steps {
sh 'mvn verify';
}
}
stage('Deploy release') {
when {
allOf {
branch 'master'
environment name:'IS_SNAPSHOT', value: 'false'
}
}
steps {
echo "Deploy new release...";
sh 'mvn clean deploy -P deploy';
}
}
stage('Prepare cloud zip') {
steps {
echo "Creating cloud zip...";
sh "rm -rf ReformCloud2.zip";
sh "mkdir -p results";
sh "cp -r .templates/* results/";
sh "cp reformcloud2-runner/target/runner.jar results/runner.jar";
zip archive: true, dir: 'results', glob: '', zipFile: 'ReformCloud2.zip';
sh "rm -rf results/";
}
}
stage('Prepare applications zip') {
steps {
sh "rm -rf ReformCloud2-Applications.zip";
sh "mkdir -p applications/";
sh "find reformcloud2-applications/ -type f -name \"reformcloud2-default-*.jar\" -and -not -name \"*-sources.jar\" -and -not -name \"*-javadoc.jar\" -exec cp \"{}\" applications/ ';'";
zip archive: true, dir: 'applications', glob: '', zipFile: 'ReformCloud2-Applications.zip'
sh "rm -rf applications/";
}
}
stage('Prepare plugins zip') {
steps {
sh "rm -rf ReformCloud2-Plugins.zip";
sh "mkdir -p plugins/";
sh "find reformcloud2-plugins/ -type f -name \"reformcloud2-default-*.jar\" -and -not -name \"*-sources.jar\" -and -not -name \"*-javadoc.jar\" -exec cp \"{}\" plugins/ ';'";
zip archive: true, dir: 'plugins', glob: '', zipFile: 'ReformCloud2-Plugins.zip'
sh "rm -rf plugins/";
}
}
stage('Archive') {
steps {
archiveArtifacts artifacts: 'ReformCloud2.zip'
archiveArtifacts artifacts: 'ReformCloud2-Applications.zip'
archiveArtifacts artifacts: 'ReformCloud2-Plugins.zip'
archiveArtifacts artifacts: 'reformcloud2-runner/target/runner.jar'
archiveArtifacts artifacts: 'reformcloud2-node/target/executor.jar'
archiveArtifacts artifacts: 'reformcloud2-embedded/target/embedded.jar'
}
}
}
post {
always {
withCredentials([string(credentialsId: 'discord-webhook', variable: 'url')]) {
discordSend description: 'New build of ReformCloud', footer: 'Update', link: BUILD_URL, successful: currentBuild.resultIsBetterOrEqualTo('SUCCESS'), title: JOB_NAME, webhookURL: url
}
}
success {
junit allowEmptyResults: true, testResults: 'reformcloud2-executor-api/target/surefire-reports/TEST-*.xml'
junit allowEmptyResults: true, testResults: 'reformcloud2-protocol/target/surefire-reports/TEST-*.xml'
junit allowEmptyResults: true, testResults: 'reformcloud2-shared/target/surefire-reports/TEST-*.xml'
}
}
}
def getProjectVersion() {
return sh(script: "mvn help:evaluate -Dexpression=project.version -q -DforceStdout | tail -1", returnStdout: true)
}