This repository has been archived by the owner on Dec 13, 2023. It is now read-only.
forked from spring-projects/spring-pulsar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
126 lines (123 loc) · 3.75 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
@Library('[email protected]') _
String slackChannel = '#em-pipeline'
Map<String, ?> config = [:]
Map<String, ?> fossaScanOptions = config.fossaScanOptions ?: [:] as Map<String, ?>
pipeline {
agent any
tools {
jdk 'collibra-zulu11.60.19-jdk11.0.17'
}
options {
disableConcurrentBuilds()
buildDiscarder(logRotator(numToKeepStr: '40'))
timestamps()
durabilityHint('PERFORMANCE_OPTIMIZED')
}
environment {
NEXUS = credentials('nexus-gradle')
GRADLE_ENTERPRISE_ACCESS_KEY = credentials('GRADLE_ENTERPRISE_ACCESS_KEY')
VERSION = '0.0.1-jdk11'
MAIN_BRANCH = 'main_jdk11'
}
parameters {
booleanParam(name: 'SKIP_PUBLISH', defaultValue: false, description: 'skip publish step')
booleanParam(name: 'FORCE_DOCS_PUBLISH', defaultValue: false, description: 'force a structurizr & devdocs publish')
}
stages {
stage('Setup') {
steps {
ontrackSetup(
autoValidationStampCreation: true
)
}
}
stage('Build') {
steps {
script {
doGradle('build')
}
}
post {
always {
script {
ontrackCreateBuild env.BUILD_ID, env.GIT_COMMIT
def results = ontrackValidationForJUnit pattern: '**/build/test-results/**/*.xml', build: env.BUILD_ID, validation: 'build'
slackStageNotification channel: slackChannel, results: results
}
}
}
}
stage('Fossa Scan') {
when {
branch env.MAIN_BRANCH
}
steps {
script {
fossaScan(fossaScanOptions)
}
}
post {
always {
ontrackSetValidation build: env.BUILD_ID, validation: 'fossaScan'
}
}
}
stage('Publication') {
when {
allOf {
not {
expression { params.SKIP_PUBLISH == true }
}
branch env.MAIN_BRANCH
}
}
steps {
script {
currentBuild.description = "Version ${env.VERSION}"
doGradle('publish')
}
tagging(
name: env.VERSION,
commit: env.GIT_COMMIT,
)
}
post {
always {
slackStageNotification channel: slackChannel
ontrackSetValidation build: env.BUILD_ID, validation: 'tagging'
ontrackSetValidation build: env.BUILD_ID, validation: 'nexus'
}
}
}
stage('Dev Documentation') {
when {
beforeAgent true
anyOf {
expression { params.FORCE_DOCS_PUBLISH == true }
branch env.MAIN_BRANCH
}
}
environment {
GRGIT_USER = credentials('github-collibra-cicd-token')
}
steps {
withCredentials([
usernamePassword(credentialsId: 'nexus-gradle', usernameVariable: 'NEXUS_USR', passwordVariable: 'NEXUS_PSW'),
]) {
doGradle('gitPublishPush')
}
}
}
}
}
def doGradle(String... tasks) {
sh """\
./gradlew \\
${tasks.join(' ')} \\
-PnexusUserName=${NEXUS_USR} \\
-PnexusPassword=${NEXUS_PSW} \\
--console plain \\
--info \\
--stacktrace
"""
}