forked from geogebra/geogebra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
143 lines (139 loc) · 5.82 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
@NonCPS
def getChangelog() {
def changeLogSets = currentBuild.changeSets
def lines = []
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 nodeLabel = isGiac ? "Ubuntu" : "posix"
def s3buildDir = "geogebra/branches/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/"
def s3uploadDefault = { dir, pattern, encoding ->
withAWS (region:'eu-central-1', credentials:'aws-credentials') {
if (!pattern.contains(".zip")) {
s3Upload(bucket: 'apps-builds', workingDir: dir, path: s3buildDir,
includePathPattern: pattern, acl: 'PublicRead', contentEncoding: encoding)
}
s3Upload(bucket: 'apps-builds', workingDir: dir, path: "geogebra/branches/${env.GIT_BRANCH}/latest/",
includePathPattern: pattern, acl: 'PublicRead', contentEncoding: encoding)
}
}
pipeline {
options {
gitLabConnection('git.geogebra.org')
buildDiscarder(logRotator(numToKeepStr: '30'))
}
agent {label nodeLabel}
stages {
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: "./gradlew :web:prepareS3Upload :web:createDraftBundleZip :web:mergeDeploy -Pgdraft=true -PdeployggbRoot=https://apps-builds.s3-eu-central-1.amazonaws.com/${s3buildDir}"
}
}
stage('tests and reports') {
when {
expression {return !isGiac}
}
steps {
sh label: 'test', script: "./gradlew test :common-jre:jacocoTestReport"
sh label: 'static analysis', script: './gradlew pmdMain spotbugsMain -x common:spotbugsMain -x renderer-base:spotbugsMain --max-workers=1'
sh label: 'spotbugs common', script: './gradlew :common:spotbugsMain'
sh label: 'code style', script: './gradlew :web:cpdCheck checkStyleMain checkStyleTest'
junit '**/build/test-results/test/*.xml'
recordIssues tools: [
cpd(pattern: '**/build/reports/cpd/cpdCheck.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')
]
publishCoverage adapters: [jacocoAdapter('**/build/reports/jacoco/test/*.xml')],
sourceFileResolver: sourceFiles('NEVER_STORE')
}
}
stage('giac test') {
when {
expression {return isGiac}
}
parallel {
stage('mac') {
agent {label 'mac'}
steps {
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: "./gradlew :desktop:test"
junit '**/build/test-results/test/*.xml'
}
post {
always { deleteDir() }
}
}
stage('windows') {
agent {label 'winbuild'}
steps {
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/")
}
s3uploadDefault(".", "changes.csv", "")
s3uploadDefault("web/build/s3", "webSimple/**", "gzip")
s3uploadDefault("web/build/s3", "web3d/**", "gzip")
s3uploadDefault("web/war", "**/*.html", "")
s3uploadDefault("web/war", "**/deployggb.js", "")
s3uploadDefault("web/war", "*.zip", "")
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()
}
}
}