forked from James471/geogebra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
87 lines (84 loc) · 3.85 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
@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 s3uploadDefault = { dir, pattern, encoding ->
withAWS (region:'eu-central-1', credentials:'aws-credentials') {
if (!pattern.contains(".zip")) {
s3Upload(bucket: 'apps-builds', workingDir: dir, path: "geogebra/branches/${env.GIT_BRANCH}/${env.BUILD_NUMBER}/",
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')
}
agent any
stages {
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'
sh label: 'test', script: "./gradlew :common-jre:test :desktop:test :common-jre:jacocoTestReport :web:test"
sh label: 'static analysis', script: './gradlew checkPmd :editor-base:spotbugsMain :web:spotbugsMain :desktop:spotbugsMain :ggbjdk:spotbugsMain :common-jre:spotbugsMain --max-workers=1'
sh label: 'spotbugs common', script: './gradlew :common:spotbugsMain'
sh label: 'code style', script: './gradlew :web:cpdCheck checkAllStyles'
}
}
stage('reports') {
steps {
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('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", "")
}
}
}
}
post {
unsuccessful {
updateGitlabCommitStatus name: 'build', state: 'failed'
}
success {
updateGitlabCommitStatus name: 'build', state: 'success'
}
always {
cleanAndNotify()
}
}
}