forked from LORD-MicroStrain/mip_sdk
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
154 lines (151 loc) · 5.32 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
// 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 {
if (env.CHANGE_BRANCH) {
BRANCH_NAME_REAL = env.CHANGE_BRANCH
} else {
BRANCH_NAME_REAL = env.BRANCH_NAME
}
}
// 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/libmip.git']],
extensions: [
]
])
}
pipeline {
agent none
stages {
stage('Build') {
// Run the windows and linux builds in parallel
parallel {
stage('Windows x86') {
agent { label 'windows10' }
options { skipDefaultCheckout() }
steps {
checkoutRepo()
powershell """
mkdir build_Win32
cd build_Win32
cmake .. `
-A "Win32" `
-T "v142" `
-DBUILD_DOCUMENTATION=ON `
-DBUILD_PACKAGE=ON
cmake --build . -j
cmake --build . --target package
cmake --build . --target package_docs
"""
archiveArtifacts artifacts: 'build_Win32/mipsdk_*'
}
}
stage('Windows x64') {
agent { label 'windows10' }
options { skipDefaultCheckout() }
steps {
checkoutRepo()
powershell """
mkdir build_x64
cd build_x64
cmake .. `
-A "x64" `
-T "v142" `
-DBUILD_PACKAGE=ON
cmake --build . -j
cmake --build . --target package
"""
archiveArtifacts artifacts: 'build_x64/mipsdk_*'
}
}
stage('Ubuntu amd64') {
agent { label 'linux-amd64' }
options { skipDefaultCheckout() }
steps {
checkoutRepo()
sh "./.devcontainer/docker_build.sh --os ubuntu --arch amd64"
archiveArtifacts artifacts: 'build_ubuntu_amd64/mipsdk_*'
}
}
stage('Centos amd64') {
agent { label 'linux-amd64' }
options { skipDefaultCheckout() }
steps {
checkoutRepo()
sh "./.devcontainer/docker_build.sh --os centos --arch amd64"
archiveArtifacts artifacts: 'build_centos_amd64/mipsdk_*'
}
}
// stage('Ubuntu arm64') {
// agent { label 'linux-arm64' }
// options { skipDefaultCheckout() }
// steps {
// checkoutRepo()
// sh "./.devcontainer/docker_build.sh --os ubuntu --arch arm64v8"
// archiveArtifacts artifacts: 'build_ubuntu_arm64v8/mipsdk_*'
// }
// }
// stage('Ubuntu arm32') {
// agent { label 'linux-arm64' }
// options { skipDefaultCheckout() }
// steps {
// checkoutRepo()
// sh "./.devcontainer/docker_build.sh --os ubuntu --arch arm32v7"
// archiveArtifacts artifacts: 'build_ubuntu_arm32v7/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
./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
'''
}
}
}
}
}
}
}
}