-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathJenkinsfile.nightly
152 lines (150 loc) · 6.26 KB
/
Jenkinsfile.nightly
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
def scmVars
@Library('jenkins-shared-lib') _
// TODO
// * Generate badge for test failure and add it to the readme.md
// https://github.com/jenkinsci/embeddable-build-status-plugin#embeddable-build-status-plugin is already installed
// Either generate Sonar badges as well (can I access Sonar API from pipeline? Probably...), or make Sonar project public
// * https://github.com/jenkinsci/git-forensics-plugin and https://github.com/jenkinsci/forensics-api-plugin allow the discovery of reference builds
// publishCoverage adapters: [jacocoAdapter(mergeToOneReport: true, path: '')], globalThresholds: [[thresholdTarget: 'Aggregated Report']], sourceFileResolver: sourceFiles('NEVER_STORE')
// https://www.jenkins.io/blog/2019/07/21/Jenkins-code-coverage-diff-for-pull-request/
// * TODO: It might be necessary to change the maven build to use cobertura instead of jacoco to support delta for test cases
// * Exclude certain classes from coverage (i.e., UltimateTest, java.bdd, ...)
// * Access test results for dependent nightly release and mattermost messages https://stackoverflow.com/questions/39920437/how-to-access-junit-test-counts-in-jenkins-pipeline-project
pipeline {
agent { label 'linux && java' }
triggers {
cron('@midnight')
}
options {
skipDefaultCheckout()
timeout(time: 12, unit: 'HOURS')
timestamps()
}
environment {
PATH = "${env.WORKSPACE}/releaseScripts/default/adds:${env.PATH}"
}
tools {
jdk 'JDK21'
maven 'Maven 3.9.8'
}
stages {
stage('Checkout') {
steps {
script {
scmVars = checkout scm
echo "Building for ${currentBuild.changeSets.size()} changes"
}
sh 'git clean -f -x -d'
}
}
stage('Check environment') {
when {
anyOf {
expression { return util.hasChanges(scmVars) }
triggeredBy cause: 'UserIdCause'
}
}
steps {
sh(label: 'check solvers', script: 'releaseScripts/default/check_solvers.sh')
}
}
// stage('Collect repository statistics') {
// //TODO: Runs really long, perhaps it should be a separate job or
// when {
// allOf {
// //branch 'dev'
// expression { return !currentBuild.changeSets.isEmpty() }
// }
// }
// steps {
// catchError(buildResult: null, catchInterruptions: false) {
// mineRepository()
// }
// }
// }
stage('Collect reference build') {
when {
anyOf {
expression { return util.hasChanges(scmVars) }
triggeredBy cause: 'UserIdCause'
}
}
steps {
catchError(buildResult: null, catchInterruptions: false) {
discoverGitReferenceBuild(latestBuildIfNotFound: true, targetBranch: 'dev')
}
}
}
stage('Build and run nightly tests') {
when {
anyOf {
expression { return util.hasChanges(scmVars) }
triggeredBy cause: 'UserIdCause'
}
}
steps {
withMaven(mavenOpts: '-Xmx4g -Xss4m -ea', options: [artifactsPublisher(disabled: true), junitPublisher(healthScaleFactor: 1.0, keepLongStdio: true, skipPublishingChecks: false)]) {
sh 'cd trunk/source/BA_MavenParentUltimate && mvn -T 1C clean install -Pcoverage -Dmaven.test.failure.ignore=true -DexcludedGroups=de.uni_freiburg.informatik.ultimate.test.junitextension.categories.NoRegression'
}
}
}
// stage('Report'){
// steps {
// junit keepLongStdio: true, testResults: 'prototype/test_results.xml'
// cobertura coberturaReportFile: 'prototype/cov-cobertura.xml'
// catchError(buildResult: 'SUCCESS', catchInterruptions: false) {
// //do not let coverage result errors fail the build
// publishCoverage adapters: [coberturaAdapter('prototype/cov-cobertura.xml')], calculateDiffForChangeRequests: true, sourceFileResolver: sourceFiles('NEVER_STORE')
// }
// }
// }
stage('Run Sonar') {
when {
allOf {
expression { return currentBuild.result == 'SUCCESS' || currentBuild.result == 'UNSTABLE' }
branch 'dev'
anyOf {
expression { return util.hasChanges(scmVars) }
triggeredBy cause: 'UserIdCause'
}
}
}
steps {
withCredentials([string(credentialsId: 'SonarTokenJenkinsPipeline', variable: 'SONAR_TOKEN')]) {
withMaven(mavenOpts: '-Xmx4g -Xss4m', options: [jacocoPublisher()], publisherStrategy: 'EXPLICIT', traceability: true) {
sh 'cd trunk/source/BA_MavenParentUltimate && mvn install -Psonar -Dsonar.host.url=https://sonar.sopranium.de -Dsonar.token=$SONAR_TOKEN'
}
}
}
}
stage('Deploy nightly build') {
when {
allOf {
branch 'dev'
expression { return util.hasChanges(scmVars) }
expression { return currentBuild.result == 'SUCCESS' || currentBuild.result == 'UNSTABLE' }
}
}
steps {
withMaven(mavenOpts: '-Xmx4g -Xss4m', publisherStrategy: 'EXPLICIT') {
sh 'cd releaseScripts/default && ./makeFresh.sh'
}
sshagent(credentials: ['jenkins-deploy']) {
sh(label: 'deploy nightly to struebli', script: 'releaseScripts/default/deploy_nightly_to_struebli.sh')
}
}
}
}
post {
unsuccessful {
script { string mmMessage = mattermost.create_mattermost_message(scmVars) }
emailext(body: '$DEFAULT_CONTENT', mimeType: 'text/plain', recipientProviders: [culprits(), developers(), requestor()], replyTo: '[email protected]', subject: '$DEFAULT_SUBJECT')
mattermostSend(color: "${env.mm_color}", message: "${mmMessage}", text: '', channel: '#ultimate', icon: 'https://jenkins.sopranium.de/static/0e41ff2a/images/jenkins-header-logo-v2.svg')
}
fixed {
script { string mmMessage = mattermost.create_mattermost_message(scmVars) }
emailext(body: '$DEFAULT_CONTENT', mimeType: 'text/plain', recipientProviders: [culprits(), developers(), requestor()], replyTo: '[email protected]', subject: '$DEFAULT_SUBJECT')
mattermostSend(color: "${env.mm_color}", message: "${mmMessage}", text: '', channel: '#ultimate', icon: 'https://jenkins.sopranium.de/static/0e41ff2a/images/jenkins-header-logo-v2.svg')
}
}
}