forked from hibernate/hibernate-asciidoctor-extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
86 lines (82 loc) · 3.6 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
@Library('[email protected]') _
import org.hibernate.jenkins.pipeline.helpers.version.Version
pipeline {
agent {
label 'Worker&&Containers'
}
tools {
maven 'Apache Maven 3.8'
jdk 'OpenJDK 17 Latest'
}
options {
buildDiscarder logRotator(daysToKeepStr: '30', numToKeepStr: '10')
disableConcurrentBuilds(abortPrevious: false)
}
parameters {
string(
name: 'RELEASE_VERSION',
defaultValue: '',
description: 'The version to be released, e.g. 7.1.0.Final.',
trim: true
)
string(
name: 'DEVELOPMENT_VERSION',
defaultValue: '',
description: 'The next version to be used after the release, e.g. 7.2.0-SNAPSHOT.',
trim: true
)
booleanParam(
name: 'RELEASE_DRY_RUN',
defaultValue: false,
description: 'If true, just simulate the release, without pushing any commits or tags, and without uploading any artifacts or documentation.'
)
}
stages {
stage('Build') {
steps {
withMaven(mavenLocalRepo: env.WORKSPACE_TMP + '/.m2repository') {
sh "./mvnw clean verify"
}
}
}
stage('Release') {
when {
beforeAgent true
// Releases must be triggered explicitly with parameters
expression { return params.RELEASE_VERSION }
}
steps {
script {
// Check that all the necessary parameters are set
if (!params.RELEASE_VERSION) {
throw new IllegalArgumentException("Missing value for parameter RELEASE_VERSION.")
}
if (!params.DEVELOPMENT_VERSION) {
throw new IllegalArgumentException("Missing value for parameter DEVELOPMENT_VERSION.")
}
def releaseVersion = Version.parseReleaseVersion(params.RELEASE_VERSION)
def developmentVersion = Version.parseDevelopmentVersion(params.DEVELOPMENT_VERSION)
echo "Performing full release for version ${releaseVersion.toString()}"
withMaven(mavenSettingsConfig: params.RELEASE_DRY_RUN ? null : 'ci-hibernate.deploy.settings.maven',
mavenLocalRepo: env.WORKSPACE_TMP + '/.m2repository') {
configFileProvider([configFile(fileId: 'release.config.ssh', targetLocation: env.HOME + '/.ssh/config'),
configFile(fileId: 'release.config.ssh.knownhosts', targetLocation: env.HOME + '/.ssh/known_hosts')]) {
sshagent(['ed25519.Hibernate-CI.github.com']) {
sh 'cat $HOME/.ssh/config'
sh """ \
./mvnw release:prepare \
-Dtag=${releaseVersion.toString()} \
-DreleaseVersion=${releaseVersion.toString()} \
-DdevelopmentVersion=${developmentVersion.toString()} \
"""
sh """ \
./mvnw release:perform ${params.RELEASE_DRY_RUN ? '-DdryRun' : ''} \
"""
}
}
}
}
}
}
}
}