-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJenkinsfile.release
More file actions
103 lines (90 loc) · 4.37 KB
/
Jenkinsfile.release
File metadata and controls
103 lines (90 loc) · 4.37 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
pipeline {
agent {
label "DS agent"
}
options {
disableConcurrentBuilds()
timeout(time: 40, unit: "MINUTES")
buildDiscarder(logRotator(numToKeepStr: "5"))
}
environment {
PROJECT = "ds-license"
BUILD_TO_TRIGGER = "ds-present"
}
parameters {
string(name: "VERSION", defaultValue: "X.X.X", description: "Version to release")
string(name: "PARENT_VERSION", defaultValue: "X.X.X", description: "Version to release")
string(name: "SHARED_VERSION", defaultValue: "X.X.X", description: "Version to release")
string(name: "STORAGE_VERSION", defaultValue: "X.X.X", description: "Version to release")
}
stages {
stage("Print Version") {
steps {
echo "Version: ${params.VERSION}"
}
}
stage("Check Version") {
steps {
script {
if ( !params.VERSION || params.VERSION == "X.X.X" ) {
currentBuild.description = "No valid version"
currentBuild.result = "ABORTED"
error("Stopping pipeline: No valid version is set.")
}
}
}
}
stage('Setup Versions') {
steps {
script {
def defaultValue = 'X.X.X'
env.PARENT_VERSION = (params.PARENT_VERSION in [defaultValue, '', null]) ? params.VERSION : params.PARENT_VERSION
env.SHARED_VERSION = (params.SHARED_VERSION in [defaultValue, '', null]) ? params.VERSION : params.SHARED_VERSION
env.STORAGE_VERSION = (params.STORAGE_VERSION in [defaultValue, '', null]) ? params.VERSION : params.STORAGE_VERSION
env.VERSION = params.VERSION
echo "Versions configured:"
echo " VERSION: ${env.VERSION}"
echo " PARENT_VERSION: ${env.PARENT_VERSION}"
echo " SHARED_VERSION: ${env.SHARED_VERSION}"
echo " STORAGE_VERSION: ${env.STORAGE_VERSION}"
}
}
}
stage("Change version") {
steps {
withMaven(options: [artifactsPublisher(fingerprintFilesDisabled: true, archiveFilesDisabled: true)], traceability: true, mavenLocalRepo: "${WORKSPACE}/repository") {
sh "mvn versions:set -DnewVersion=${env.VERSION} -DgenerateBackupPoms=false"
echo "Changing MVN version to: ${env.VERSION}"
}
}
}
stage("Update parent") {
steps {
withMaven(options: [artifactsPublisher(fingerprintFilesDisabled: true, archiveFilesDisabled: true)], traceability: true, mavenLocalRepo: "${WORKSPACE}/repository") {
sh """sed -i "/<parent>/,/<version>/ s/<version>.*<\\/version>/<version>${env.PARENT_VERSION}<\\/version>/" pom.xml"""
echo "Changing parent to: ${env.PARENT_VERSION}"
}
}
}
stage("Change dependencies") {
steps {
withMaven(options: [artifactsPublisher(fingerprintFilesDisabled: true, archiveFilesDisabled: true)], traceability: true, mavenLocalRepo: "${WORKSPACE}/repository") {
sh "mvn versions:use-dep-version -Dincludes=dk.kb.dsshared:* -DdepVersion=${env.SHARED_VERSION} -DforceVersion=true -DgenerateBackupPoms=false"
echo "Changing MVN dependencies to: ${env.SHARED_VERSION}"
}
withMaven(options: [artifactsPublisher(fingerprintFilesDisabled: true, archiveFilesDisabled: true)], traceability: true, mavenLocalRepo: "${WORKSPACE}/repository") {
sh "mvn versions:use-dep-version -Dincludes=dk.kb.storage:* -DdepVersion=${env.STORAGE_VERSION} -DforceVersion=true -DgenerateBackupPoms=false"
echo "Changing MVN dependencies to: ${env.STORAGE_VERSION}"
}
}
}
stage("Release to Nexus") {
steps {
withMaven(options: [artifactsPublisher(fingerprintFilesDisabled: true, archiveFilesDisabled: true)], traceability: true, mavenLocalRepo: "${WORKSPACE}/repository") {
// Execute Maven Release
sh "mvn clean deploy"
}
}
}
}
}