-
Notifications
You must be signed in to change notification settings - Fork 345
/
Jenkinsfile
165 lines (162 loc) · 7.24 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
@NonCPS
def getChangelog() {
def changeLogSets = currentBuild.changeSets
def lines = []
lines << "${env.GIT_COMMIT},-,${new Date()},Build ${env.BUILD_NUMBER}"
for (int i = 0; i < changeLogSets.size(); i++) {
def entries = changeLogSets[i].items
for (int j = 0; j < entries.length; j++) {
def entry = entries[j]
lines << "${entry.commitId},${entry.author.toString()},${new Date(entry.timestamp)},${entry.msg}"
}
}
return lines.join("\n").toString()
}
def isGiac = env.BRANCH_NAME.matches("(dependabot.*)?giac.*")
def isEditor = env.BRANCH_NAME.matches("dev|(.*editor)")
def hasSourcemap = env.BRANCH_NAME.matches("dev|mow-1378")
def modules = isEditor ? '-Pgmodule="org.geogebra.web.SuperWeb,org.geogebra.web.WebSimple,org.geogebra.web.Editor"' : ''
def nodeLabel = isGiac ? "Ubuntu" : "posix"
def s3buildDir = "geogebra/branches/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/"
// to run in docker, add docker run --ipc=host --shm-size=1gb -u $(id -u):$(id -g) -e HOME=/work -w /work -v $PWD:/work openjdk:11.0.16-jdk
def gradleCmd = './gradlew'
def s3uploadDefault = { dir, pattern, encoding, excludes="**/*.mjs", contentType="" ->
withAWS (region:'eu-central-1', credentials:'aws-credentials') {
if (!pattern.contains("editor/")) {
s3Upload(bucket: 'apps-builds', workingDir: dir, path: s3buildDir, contentType: contentType,
includePathPattern: pattern, acl: 'PublicRead', contentEncoding: encoding, excludePathPattern: excludes)
}
s3Upload(bucket: 'apps-builds', workingDir: dir, path: "geogebra/branches/${env.GIT_BRANCH}/latest/",
includePathPattern: pattern, acl: 'PublicRead', contentEncoding: encoding, excludePathPattern: excludes,
contentType: contentType)
}
}
pipeline {
options {
gitLabConnection('git.geogebra.org')
buildDiscarder(logRotator(numToKeepStr: '30'))
}
agent {label nodeLabel}
stages {
stage('skip on message') {
steps { scmSkip(deleteBuild: false, skipPattern:'.*\\[ci skip\\].*') }
}
stage('cancel prev builds') {
when {
expression { return env.BRANCH_NAME != 'master' && env.BRANCH_NAME != 'dev' }
}
steps {
milestone label: '', ordinal: Integer.parseInt(env.BUILD_ID) - 1
milestone label: '', ordinal: Integer.parseInt(env.BUILD_ID)
}
}
stage('build') {
steps {
updateGitlabCommitStatus name: 'build', state: 'pending'
writeFile file: 'changes.csv', text: getChangelog()
sh label: 'build web', script: "$gradleCmd :web:prepareS3Upload :web:mergeDeploy ${modules} -Pgdraft=true -PdeployggbRoot=https://apps-builds.s3-eu-central-1.amazonaws.com/${s3buildDir}"
}
}
stage('tests and reports') {
when {
expression {return !isGiac}
}
steps {
sh "$gradleCmd test :common-jre:jacocoTestReport spotbugsMain pmdMain checkStyleMain checkStyleTest -x renderer-base:spotbugsMain"
junit '**/build/test-results/test/*.xml'
recordIssues qualityGates: [[threshold: 1, type: 'TOTAL', unstable: true]], tools: [
spotBugs(pattern: '**/build/reports/spotbugs/*.xml', useRankAsPriority: true),
pmdParser(pattern: '**/build/reports/pmd/main.xml'),
checkStyle(pattern: '**/build/reports/checkstyle/*.xml')
]
recordCoverage sourceCodeRetention: 'NEVER', tools: [[pattern: '**/build/reports/jacoco/test/*.xml']]
}
}
stage('giac test') {
when {
expression {return isGiac}
}
parallel {
stage('mac-amd64') {
agent {label 'ios-test'}
steps {
sh label: 'test', script: "./gradlew :desktop:test"
junit '**/build/test-results/test/*.xml'
}
post {
always { deleteDir() }
}
}
stage('mac-arm64') {
agent {label 'mac-mini'}
steps {
// NOT using docker to make sure this runs Giac for Mac
sh label: 'test', script: "./gradlew :desktop:test"
junit '**/build/test-results/test/*.xml'
}
post {
always { deleteDir() }
}
}
stage('linux') {
agent {label 'Ubuntu'}
steps {
sh label: 'test', script: "$gradleCmd :desktop:test"
junit '**/build/test-results/test/*.xml'
}
post {
always { deleteDir() }
}
}
stage('windows') {
agent {label 'winbuild'}
steps {
// NOT using docker to make sure this runs Giac for Windows
bat label: 'test', script: ".\\gradlew.bat :desktop:test"
junit '**/build/test-results/test/*.xml'
}
post {
always { deleteDir() }
}
}
}
}
stage('archive') {
steps {
script {
withAWS (region:'eu-central-1', credentials:'aws-credentials') {
s3Delete(bucket: 'apps-builds', path: "geogebra/branches/${env.GIT_BRANCH}/latest/")
if (hasSourcemap) {
s3Upload(bucket: 'apps-builds', workingDir: "web/build/symbolMapsGz", path: "geogebra/sourcemaps/",
includePathPattern: "**/*.json", acl: 'PublicRead', contentEncoding: "gzip")
}
}
s3uploadDefault(".", "changes.csv", "")
s3uploadDefault("web/build/s3", "webSimple/**", "gzip")
s3uploadDefault("web/build/s3", "web3d/**", "gzip")
if (isEditor) {
s3uploadDefault("web/build/s3", "editor/**", "gzip")
s3uploadDefault("web/build/s3", "editor/**/*.mjs", "gzip", "", "text/javascript")
}
s3uploadDefault("web/build/s3", "web3d/**/*.mjs", "gzip", "", "text/javascript")
s3uploadDefault("web/war", "**/*.html", "")
s3uploadDefault("web/war", "**/deployggb.js", "")
s3uploadDefault("web/war", "geogebra-live.js", "")
s3uploadDefault("web/war", "platform.js", "")
s3uploadDefault("web/war", "css/**", "")
}
}
}
}
post {
unsuccessful {
updateGitlabCommitStatus name: 'build', state: 'failed'
}
success {
updateGitlabCommitStatus name: 'build', state: 'success'
}
always {
cleanAndNotify()
}
}
}