-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
219 lines (208 loc) · 8.22 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
pipeline {
/* Use docker image from tools/build-env folder */
agent {
dockerfile {
filename 'Dockerfile_ubuntu_2404'
dir 'tools/build-env'
args '--mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock -u 0:0'
}
}
environment {
/* Collect versions saved in tools/ folder */
FULL_VERSION = sh(script: "./tools/get_version.sh full", returnStdout: true).trim()
SHORT_VERSION = sh(script: "./tools/get_version.sh", returnStdout: true).trim()
BRANCH_FOLDER = sh(script: "./tools/get_branch_folder.sh ${BRANCH_NAME}", returnStdout: true).trim()
RUST_STATIC_FLAGS = '-C target-feature=-crt-static'
}
stages {
stage('Download prerequisites') {
steps {
dir('ttg') {
git url: 'https://github.com/maximmenshikov/ttg.git',
branch: 'main'
}
}
}
stage('Perform checks') {
steps {
/* Mark directory as safe - we might have dubious permissions here due to uid manipulations */
sh 'git config --global --add safe.directory "*"'
/* Update Cargo */
sh 'cargo update -p isabelle-dm'
/* Fail if 'cargo fix' changes anything */
sh 'cargo fix && git diff --exit-code'
/* Fail if 'cargo fmt' changes anything */
sh 'cargo fmt && git diff --exit-code'
/* Fail if Cargo.toml is not updated with current version */
sh 'cat Cargo.toml | grep ${SHORT_VERSION}'
}
}
stage('Perform release checks') {
when {
expression {
BRANCH_NAME == 'main'
}
}
steps {
/* Fail if tag is not updated with current version */
sh 'git tag | grep ${SHORT_VERSION}'
}
}
stage('Build for all platforms') {
parallel {
stage('Build (Linux)') {
steps {
sh 'which cargo'
sh 'env RUSTFLAGS="${RUST_STATIC_FLAGS}" CROSS_CONTAINER_UID=0 CROSS_CONTAINER_GID=0 CROSS_CONTAINER_IN_CONTAINER=true CROSS_NO_WARNINGS=0 cross build --target=x86_64-unknown-linux-gnu --release'
sh 'chmod -R 777 target'
}
}
}
}
stage('Prepare bundle') {
stages {
/* Right now, we build just for Linux, that's the preferred platform for */
stage('Prepare artifacts (branch)') {
steps {
sh 'mkdir -p build && (rm -rf build/* || true)'
/* Create branch-build-linux and doc-branch-build */
sh './tools/release.sh --out build/isabelle-core-${BRANCH_FOLDER}-${BUILD_NUMBER}-linux-x86_64.tar.xz'
/* Copy branch-build-linux to branch-latest-linux */
sh 'cp build/isabelle-core-${BRANCH_FOLDER}-${BUILD_NUMBER}-linux-x86_64.tar.xz build/isabelle-core-${BRANCH_FOLDER}-latest-linux-x86_64.tar.xz'
/* chmod build folder */
sh 'chmod -R 777 build'
}
}
stage('Prepare artifacts (versioned)') {
when {
expression {
BRANCH_NAME == 'main'
}
}
steps {
/* Create versioned artifacts */
sh 'mkdir -p build/versioned_artifacts'
/* Copy branch-latest-linux to fullver-linux */
sh 'cp build/isabelle-core-${BRANCH_FOLDER}-latest-linux-x86_64.tar.xz build/versioned_artifacts/isabelle-core-${FULL_VERSION}-linux-x86_64.tar.xz'
}
}
}
}
stage('Publish artifacts') {
parallel {
stage('Publish artifacts (branch)') {
steps {
ftpPublisher alwaysPublishFromMaster: true,
continueOnError: false,
failOnError: false,
masterNodeName: '',
paramPublish: null,
publishers: [
[
configName: 'Isabelle Core releases',
transfers:
[[
asciiMode: false,
cleanRemote: false,
excludes: '',
flatten: false,
makeEmptyDirs: false,
noDefaultExcludes: false,
patternSeparator: '[, ]+',
remoteDirectory: "branches/${BRANCH_FOLDER}-${BUILD_NUMBER}",
remoteDirectorySDF: false,
removePrefix: 'build',
sourceFiles: "build/isabelle-core-*${BRANCH_FOLDER}-${BUILD_NUMBER}*.tar.xz"
]],
usePromotionTimestamp: false,
useWorkspaceInPromotion: false,
verbose: true
]
]
ftpPublisher alwaysPublishFromMaster: true,
continueOnError: false,
failOnError: false,
masterNodeName: '',
paramPublish: null,
publishers: [
[
configName: 'Isabelle Core releases',
transfers:
[[
asciiMode: false,
cleanRemote: false,
excludes: '',
flatten: false,
makeEmptyDirs: false,
noDefaultExcludes: false,
patternSeparator: '[, ]+',
remoteDirectory: "branches/${BRANCH_FOLDER}",
remoteDirectorySDF: false,
removePrefix: 'build',
sourceFiles: "build/isabelle-core-*${BRANCH_FOLDER}-latest*.tar.xz"
]],
usePromotionTimestamp: false,
useWorkspaceInPromotion: false,
verbose: true
]
]
}
}
stage('Publish artifacts (versioned)') {
when {
expression {
BRANCH_NAME == 'main'
}
}
steps {
ftpPublisher alwaysPublishFromMaster: true,
continueOnError: false,
failOnError: false,
masterNodeName: '',
paramPublish: null,
publishers: [
[
configName: 'Isabelle Core releases',
transfers:
[[
asciiMode: false,
cleanRemote: false,
excludes: '',
flatten: false,
makeEmptyDirs: false,
noDefaultExcludes: false,
patternSeparator: '[, ]+',
remoteDirectory: "${FULL_VERSION}",
remoteDirectorySDF: false,
removePrefix: 'build/versioned_artifacts',
sourceFiles: "build/versioned_artifacts/isabelle-core-*.tar.xz"
]],
usePromotionTimestamp: false,
useWorkspaceInPromotion: false,
verbose: true
]
]
}
}
stage('Archive artifacts for Jenkins') {
steps {
archiveArtifacts artifacts: 'build/isabelle-core-*.tar.xz'
}
}
}
}
}
post {
/* Send notification to Telegram */
success {
sh './ttg/ttg_send_notification --env --ignore-bad -- "${JOB_NAME}/${BUILD_NUMBER}: PASSED"'
}
failure {
sh './ttg/ttg_send_notification --env --ignore-bad -- "${JOB_NAME}/${BUILD_NUMBER}: FAILED. See details in ${BUILD_URL}"'
}
always {
sh 'chmod -R 777 target'
sh 'chmod -R 777 build'
}
}
}