-
Notifications
You must be signed in to change notification settings - Fork 40
/
Jenkinsfile
100 lines (90 loc) · 2.72 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
@Library("[email protected]") _
pipeline {
agent {
docker {
label "do && c-8"
image "openjdk:11"
}
}
options {
// General Jenkins job properties
buildDiscarder(logRotator(numToKeepStr: '40'))
// Timestamps
timestamps()
// No durability
durabilityHint('PERFORMANCE_OPTIMIZED')
}
stages {
stage("Setup") {
steps {
ontrackCliSetup(autoValidationStamps: true)
sh '''
git config --global init.defaultBranch main
'''
}
}
stage("Build") {
steps {
sh '''
./gradlew versionDisplay versionFile --stacktrace --parallel --console plain
'''
script {
// Reads version information
def props = readProperties(file: 'build/version.properties')
env.VERSION = props.VERSION_DISPLAY
env.GIT_COMMIT = props.VERSION_COMMIT
// Creates a build
ontrackCliBuild(name: env.BUILD_NUMBER, release: env.VERSION)
}
sh '''
./gradlew build --stacktrace --parallel --console plain
'''
}
post {
always {
ontrackCliValidateTests(stamp: 'BUILD', pattern: 'build/test-results/**/*.xml')
}
}
}
stage('Release') {
when {
branch 'release/*'
}
environment {
GITHUB = credentials('github-token')
}
steps {
sh '''
./gradlew githubRelease --stacktrace --console plain \\
-PgitHubToken=${GITHUB} \\
-PgitHubCommit=${GIT_COMMIT}
'''
}
post {
always {
ontrackCliValidate(stamp: 'GITHUB.RELEASE')
}
}
}
stage('Publication') {
when {
branch 'release/*'
}
environment {
GRADLE_PLUGINS = credentials('gradle-plugins')
}
steps {
sh '''
./gradlew publishPlugins --stacktrace --console plain \\
-Pgradle.publish.key=${GRADLE_PLUGINS_USR} \\
-Pgradle.publish.secret=${GRADLE_PLUGINS_PSW}
'''
}
post {
always {
ontrackCliValidate(stamp: 'GRADLE.PLUGIN')
}
}
}
}
}