-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
102 lines (100 loc) · 3.71 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
99
100
101
102
#!/usr/bin/env groovy
pipeline {
agent any
tools {
maven 'maven-latest'
jdk 'openjdk11-zulu'
}
options {
timeout(time: 1, unit: 'HOURS')
timestamps()
}
parameters {
booleanParam(defaultValue: false, description: 'Perform Maven Release?', name: 'RELEASE_OK')
string(defaultValue: '', description: 'Release Version - Version ohne -SNAPSHOT', name: 'RELEASE_VERSION', trim: true)
string(defaultValue: '', description: 'Development version - Version mit -SNAPSHOT, die zur Entwicklung genutzt werden soll', name: 'DEVELOPMENT_VERSION', trim: true)
}
stages {
stage('Checking commit message') {
when {
allOf {
not {
buildingTag()
}
changelog '.*\\[maven-release-plugin\\].*'
}
}
steps {
script {
currentBuild.getRawBuild().getExecutor().interrupt(Result.SUCCESS)
sleep(1)
}
}
}
stage('Clone Devbasis') {
steps {
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'devbasis']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github-ssh-key', url: '[email protected]:WargearWorld/devbasis.git']]])
}
}
stage('Release') {
when {
environment name: 'RELEASE_OK', value: 'true'
}
steps {
withCredentials([
usernamePassword(credentialsId: 'wgw_nexus', usernameVariable: 'NEXUS_USERNAME', passwordVariable: 'NEXUS_TOKEN')
]) {
sshagent(['github-ssh-key']) {
sh '''
mvn --version
git config --global user.name "WargearWorld-GIT"
git config --global user.email "[email protected]"
git checkout ${BRANCH_NAME}
mvn -B release:prepare -DdevelopmentVersion=${DEVELOPMENT_VERSION} -DreleaseVersion=${RELEASE_VERSION} -s devbasis/maven/settings.xml
'''
}
}
script {
currentBuild.getRawBuild().getExecutor().interrupt(Result.SUCCESS)
sleep(1)
}
}
}
stage('Build') {
when {
changeRequest()
}
steps {
withCredentials([
usernamePassword(credentialsId: 'wgw_nexus', usernameVariable: 'NEXUS_USERNAME', passwordVariable: 'NEXUS_TOKEN')
]) {
sh '''
mvn --version
mvn -B install -s devbasis/maven/settings.xml
'''
}
script {
currentBuild.getRawBuild().getExecutor().interrupt(Result.SUCCESS)
sleep(1)
}
}
}
stage('Build and Deploy') {
when {
not {
changeRequest()
}
}
steps {
withCredentials([
usernamePassword(credentialsId: 'wgw_nexus', usernameVariable: 'NEXUS_USERNAME', passwordVariable: 'NEXUS_TOKEN')
]) {
sh '''
mvn --version
mvn -B deploy -s devbasis/maven/settings.xml
'''
}
}
}
}
}