-
Notifications
You must be signed in to change notification settings - Fork 10
/
Jenkinsfile
233 lines (229 loc) · 8 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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
// Utility function for getting the real branch name even in a pull request
def branchName() {
if (env.CHANGE_BRANCH) {
return env.CHANGE_BRANCH
} else {
return env.BRANCH_NAME
}
}
// Utility function for checking out the repo since we want all the branches and tags
def checkoutRepo() {
// Clean the workspace
cleanWs()
// Handles both PRs and branches
script {
BRANCH_NAME_REAL = branchName();
}
// Checkout the code from github
checkout([ $class: 'GitSCM',
branches: [
[name: 'refs/heads/' + BRANCH_NAME_REAL]
],
userRemoteConfigs: [[credentialsId: 'Github_User_And_Token', url: 'https://github.com/LORD-MicroStrain/mip_sdk.git']],
extensions: [
]
])
}
pipeline {
agent none
options {
// Set a timeout for the whole pipeline. The timer starts when the project is queued
timeout(time: 1, unit: 'HOURS')
}
stages {
stage('Build') {
// Run all the builds in parallel
parallel {
stage('Documentation') {
agent { label 'linux-amd64' }
options {
skipDefaultCheckout()
timeout(time: 5, activity: true, unit: 'MINUTES')
}
steps {
script {
checkoutRepo()
env.setProperty('BRANCH_NAME', branchName())
sh "./.devcontainer/docker_build.sh --os ubuntu --arch amd64 --docs"
archiveArtifacts artifacts: 'build_docs/mipsdk_*'
}
}
}
stage('Windows x86') {
agent { label 'windows10' }
options {
skipDefaultCheckout()
timeout(time: 5, activity: true, unit: 'MINUTES')
}
steps {
script {
checkoutRepo()
env.setProperty('BRANCH_NAME', branchName())
powershell """
mkdir build_Win32
cd build_Win32
cmake .. -A "Win32" -DMICROSTRAIN_BUILD_EXAMPLES=ON -DMICROSTRAIN_BUILD_PACKAGE=ON
cmake --build . --config Release
cmake --build . --config Release --target package
"""
archiveArtifacts artifacts: 'build_Win32/mipsdk_*'
}
}
}
stage('Windows x64') {
agent { label 'windows10' }
options {
skipDefaultCheckout()
timeout(time: 5, activity: true, unit: 'MINUTES')
}
steps {
script {
checkoutRepo()
env.setProperty('BRANCH_NAME', branchName())
powershell """
mkdir build_x64
cd build_x64
cmake .. -DMICROSTRAIN_BUILD_EXAMPLES=ON -DMICROSTRAIN_BUILD_PACKAGE=ON
cmake --build . --config Release
cmake --build . --config Release --target package
"""
archiveArtifacts artifacts: 'build_x64/mipsdk_*'
}
}
}
stage('Ubuntu amd64') {
agent { label 'linux-amd64' }
options {
skipDefaultCheckout()
timeout(time: 5, activity: true, unit: 'MINUTES')
}
steps {
script {
checkoutRepo()
env.setProperty('BRANCH_NAME', branchName())
sh "./.devcontainer/docker_build.sh --os ubuntu --arch amd64"
archiveArtifacts artifacts: 'build_ubuntu_amd64/mipsdk_*'
}
}
}
stage('Ubuntu arm64') {
agent { label 'linux-arm64' }
options {
skipDefaultCheckout()
timeout(time: 5, activity: true, unit: 'MINUTES')
}
steps {
script {
checkoutRepo()
env.setProperty('BRANCH_NAME', branchName())
sh "./.devcontainer/docker_build.sh --os ubuntu --arch arm64v8"
archiveArtifacts artifacts: 'build_ubuntu_arm64v8/mipsdk_*'
}
}
}
stage('Ubuntu arm32') {
agent { label 'linux-arm64' }
options {
skipDefaultCheckout()
timeout(time: 5, activity: true, unit: 'MINUTES')
}
steps {
script {
checkoutRepo()
env.setProperty('BRANCH_NAME', branchName())
sh "./.devcontainer/docker_build.sh --os ubuntu --arch arm32v7"
archiveArtifacts artifacts: 'build_ubuntu_arm32v7/mipsdk_*'
}
}
}
stage("Mac M2") {
agent { label 'mac-m2' }
options {
skipDefaultCheckout()
timeout(time: 5, activity: true, unit: 'MINUTES')
}
steps {
script {
checkoutRepo()
env.setProperty('BRANCH_NAME', branchName())
sh '''
mkdir build_mac_arm64
cd build_mac_arm64
cmake .. -DMICROSTRAIN_BUILD_EXAMPLES=ON -DMICROSTRAIN_BUILD_PACKAGE=ON -DCMAKE_BUILD_TYPE=RELEASE
cmake --build . -j $(sysctl -n hw.ncpu)
cmake --build . --target package
'''
archiveArtifacts artifacts: 'build_mac_arm64/mipsdk_*'
}
}
}
stage("Mac Intel") {
agent { label 'mac-intel' }
options {
skipDefaultCheckout()
timeout(time: 5, activity: true, unit: 'MINUTES')
}
steps {
script {
checkoutRepo()
env.setProperty('BRANCH_NAME', branchName())
sh '''
mkdir build_mac_intel
cd build_mac_intel
cmake .. -DMICROSTRAIN_BUILD_EXAMPLES=ON -DMICROSTRAIN_BUILD_PACKAGE=ON -DCMAKE_BUILD_TYPE=RELEASE
cmake --build . -j $(sysctl -n hw.ncpu)
cmake --build . --target package
'''
archiveArtifacts artifacts: 'build_mac_intel/mipsdk_*'
}
}
}
}
}
}
post {
success {
script {
if (BRANCH_NAME && BRANCH_NAME == 'develop') {
node("linux-amd64") {
dir("/tmp/mip_sdk_${env.BRANCH_NAME}_${currentBuild.number}") {
copyArtifacts(projectName: "${env.JOB_NAME}", selector: specific("${currentBuild.number}"));
withCredentials([string(credentialsId: 'Github_Token', variable: 'GH_TOKEN')]) {
sh '''
# Release to github
"${WORKSPACE}/scripts/release.sh" \
--artifacts "$(find "$(pwd)" -type f)" \
--target "${BRANCH_NAME}" \
--release "latest" \
--docs-zip "$(find "$(pwd)" -type f -name "mipsdk_*_Documentation.zip" | sort | uniq)" \
--generate-notes
'''
}
}
}
} else if (BRANCH_NAME && BRANCH_NAME == 'master') {
node("linux-amd64") {
dir("/tmp/mip_sdk_${env.BRANCH_NAME}_${currentBuild.number}") {
copyArtifacts(projectName: "${env.JOB_NAME}", selector: specific("${currentBuild.number}"));
withCredentials([string(credentialsId: 'Github_Token', variable: 'GH_TOKEN')]) {
sh '''
# Release to the latest version if the master commit matches up with the commit of that version
if (cd "${WORKSPACE}" && git describe --exact-match --tags HEAD &> /dev/null); then
# Publish a release
${WORKSPACE}/scripts/release.sh" \
--artifacts "$(find "$(pwd)" -type f)" \
--target "${BRANCH_NAME}" \
--release "$(cd ${WORKSPACE} && git describe --exact-match --tags HEAD)" \
--docs-zip "$(find "$(pwd)" -type f -name "mipsdk_*_Documentation.zip" | sort | uniq)"
else
echo "Not releasing from ${BRANCH_NAME} since the current commit does not match the latest released version commit"
fi
'''
}
}
}
}
}
}
}
}