-
Notifications
You must be signed in to change notification settings - Fork 0
/
jenkinsfile
98 lines (96 loc) · 3.39 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
92
93
94
95
96
97
98
pipeline{
agent any
options {
gitLabConnection("jenkins")
}
stages {
stage ("SetVariables"){
steps{
script
{ //seting it every time bcs they are going back to java 11 every time
env.JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"
env.PATH="${env.JAVA_HOME}/bin:${env.PATH}"
}
}
}
stage ("CalculateVersion"){
when { branch 'release/*' }
steps{
script{
sh 'echo CALCULATE VERSION STAGE'
majorMinor = env.BRANCH_NAME.split("/")[1]
echo "${majorMinor}"
versionNumber = sh(script: "echo ${majorMinor}.\$(git rev-list origin/release/${majorMinor} --count)", returnStdout: true).trim()
configFileProvider([configFile(fileId: 'maven-user-stg', variable: 'MAVEN_SETTINGS_XML')]) {
sh "mvn versions:set -DnewVersion=${versionNumber}"
}
}
}
}
stage ("MavenBuild"){
steps{
script{
sh 'echo MAVEN BUILD STAGE'
configFileProvider([configFile(fileId: 'maven-user-stg', variable: 'MAVEN_SETTINGS_XML')]) {
sh 'mvn --settings $MAVEN_SETTINGS_XML compile'
}
}
}
}
stage ("MavenTests"){
steps{
script{
sh 'echo MAVEN TEST STAGE'
configFileProvider([configFile(fileId: 'maven-user-stg', variable: 'MAVEN_SETTINGS_XML')]) {
sh 'mvn --settings $MAVEN_SETTINGS_XML test'
}
}
}
}
stage ("MavenPackage"){
steps{
script{
sh 'echo MAVEN PACKAGE STAGE'
configFileProvider([configFile(fileId: 'maven-user-stg', variable: 'MAVEN_SETTINGS_XML')]) {
sh 'mvn --settings $MAVEN_SETTINGS_XML package'
}
}
}
}
stage ("MavenVerify"){
steps{
script{
sh 'echo MAVEN VERIFY STAGE'
configFileProvider([configFile(fileId: 'maven-user-stg', variable: 'MAVEN_SETTINGS_XML')]) {
sh 'mvn --settings $MAVEN_SETTINGS_XML verify'
}
}
}
}
stage ("Publishing")
{
when { anyOf { branch 'master'; branch 'release/*' } }
steps
{
script{
echo 'PUBLISH STAGE'
configFileProvider([configFile(fileId: 'maven-user-stg', variable: 'MAVEN_SETTINGS_XML')]) {
sh 'mvn --settings $MAVEN_SETTINGS_XML deploy'
}
}
}
}
stage ("Tagging")
{
when { branch 'release/*' }
steps
{
echo 'TAGGING STAGE'
sh "git clean -n -d"
sh "git clean --force -n -d"
sh "git tag -a ${versionNumber} -m 'version ${versionNumber}}'"
sh "git push origin --tags"
}
}
}
}