forked from Thrifleganger/ci-plugin-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile-cloud
More file actions
250 lines (246 loc) · 7.92 KB
/
Jenkinsfile-cloud
File metadata and controls
250 lines (246 loc) · 7.92 KB
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
/*
This is a declarative pipeline script for Jenkins for Projucer type JUCE plugin projects
Fill the variables at the start of this file to configure the build pipeline for your plugin.
The build pipeline performs the following stages:
1) Checkout: The build pipeline is triggered for every change to the master branch. The Checkout stage sends a Slack notification that a build has been started, cleans the old workspace and clones the project locally within the Jenkins executor.
2) Build: Depending on the OS, the corresponding build system is utilized to build VST3 and AU targets.
3) Test: The plugin is subjected to a testing application called pluginval.
4) Package: The build artifacts are packaged into an installer (.exe or .pkg), code signed and notarized.
5) Deploy: The installer file is pushed to an S3 bucket
6) Post: A Slack notification is sent out regarding the status of the build
*/
/*
The project name is the name of projucer file / plugin name configured within the projucer file. Avoid spaces.
*/
def projectName = 'ci-plugin-demo'
/*
The clone URL of the git repo. Add the SSH variant which starts with "git@github.com"
*/
def gitRepoUrl = 'git@github.com:Thrifleganger/ci-plugin-demo.git'
/*
Name of the slack channel to upload the artifact and report to.
*/
def slackChannel = 'jenkins-integration'
def version = ''
def installerFile = ''
/*
Start of pipeline script.
*/
pipeline {
agent none
triggers {
pollSCM('*/2 * * * *')
}
stages {
stage("Checkout") {
matrix {
axes {
axis {
name 'platform'
values 'windows', 'mac'
}
}
stages {
stage("Checkout (platform specific)") {
agent {
label "${platform}"
}
steps {
slackSend channel: "${slackChannel}",
tokenCredentialId: 'slack-integration',
color: "good",
message: "Build started: ${env.JOB_NAME} ${env.BUILD_NUMBER} : ${env.BUILD_URL}"
cleanWs()
checkout([
$class: 'GitSCM',
branches: [[name: '*/master']],
extensions: [],
userRemoteConfigs: [[
credentialsId: 'AwsJenkinsMasterToGithub',
url: "${gitRepoUrl}"
]]
])
}
}
}
}
}
stage('Build') {
parallel {
stage('Build (Windows)') {
agent {
label 'windows'
}
steps {
echo "Building plugin for Windows"
bat """
curl -L "https://api.juce.com/api/v1/download/juce/latest/windows" -o juce.zip
jar xf juce.zip
"JUCE/projucer.exe" --set-global-search-path windows defaultJuceModulePath JUCE/modules
"JUCE/projucer.exe" --resave "${projectName}.jucer"
cd Builds/VisualStudio2019
if not defined MSBUILD_EXE set MSBUILD_EXE=C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/MSBuild/Current/Bin/MSBuild.exe
"%MSBUILD_EXE%" ${projectName}.sln /p:VisualStudioVersion=16.0 /m /p:Configuration=Release /p:Platform=x64 /p:PreferredToolArchitecture=x64
copy "x64\\Release\\VST3\\${projectName}.vst3" "..\\..\\Installer\\Windows\\${projectName}.vst3"
"""
script {
def versionScript = """
@(
"JUCE/projucer.exe" --get-version ${projectName}.jucer
)
"""
version = bat(script: versionScript, returnStdout: true).trim()
}
}
}
stage('Build (Mac)') {
agent {
label 'mac'
}
steps {
echo "Building plugin for Linux/Mac"
sh """
curl -L https://api.juce.com/api/v1/download/juce/latest/osx -o juce.zip
unzip juce
./JUCE/Projucer.app/Contents/MacOS/Projucer --resave ${projectName}.jucer
cd Builds/MacOSX
xcodebuild -configuration Release -scheme "${projectName} - All" build
cp -R `readlink build/Release/${projectName}.vst3` ../../Installer/Mac/${projectName}.vst3
cp -R `readlink build/Release/${projectName}.component` ../../Installer/Mac/${projectName}.component
"""
script {
version = sh(
script: "./JUCE/Projucer.app/Contents/MacOS/Projucer --get-version ${projectName}.jucer",
returnStdout: true
).trim()
}
}
}
}
}
stage('Test') {
parallel {
stage('Test (Windows)') {
agent {
label 'windows'
}
steps {
echo "Validating plugin"
bat """
curl -L "https://github.com/Tracktion/pluginval/releases/download/latest_release/pluginval_Windows.zip" -o pluginval.zip
jar xf pluginval.zip
pluginval.exe --validate-in-process --validate "Installer/Windows/${projectName}.vst3"
"""
}
}
stage('Test (Mac)') {
agent {
label 'mac'
}
steps {
echo "Validating plugin"
sh """
curl -L "https://github.com/Tracktion/pluginval/releases/download/latest_release/pluginval_macOS.zip" -o pluginval.zip
unzip pluginval
pluginval.app/Contents/MacOS/pluginval --validate-in-process --validate "Installer/Mac/${projectName}.vst3" || exit 1
"""
}
}
}
}
stage('Package') {
parallel {
stage('Package (Windows)') {
agent {
label 'windows'
}
steps {
echo "Packaging plugin for Windows"
bat """
curl -L https://jrsoftware.org/download.php/is.exe -o innosetup.exe
innosetup.exe /portable=1 /silent /currentuser /dir="./innosetup"
"innosetup/iscc" /DVersion=${version} "Installer/Windows/${projectName}-installer.iss"
signtool sign "Installer/Windows/Output/${projectName}-${version}.exe"
"""
script {
writeFile(file: "installerFile", text: "Installer/Windows/Output/${projectName}-${version}.exe")
}
}
}
stage('Package (Mac)') {
agent {
label 'mac'
}
steps {
echo "Packaging plugin for Linux/Mac"
withCredentials([usernamePassword(credentialsId: 'mac-code-signing', passwordVariable: 'password', usernameVariable: 'username')]) {
sh """
cd Installer/Mac
sh ./install.sh -u ${username} -p ${password} -v ${version}
"""
}
script {
writeFile(file: "installerFile", text: "Installer/Mac/build/${projectName}-${version}.pkg")
}
}
}
}
}
stage('Deploy') {
matrix {
axes {
axis {
name 'platform'
values 'windows', 'mac'
}
}
stages {
stage("Deploy (platform specific)") {
agent {
label "${platform}"
}
steps {
script {
installerFile = readFile(file: 'installerFile').trim()
}
s3Upload consoleLogLevel: 'INFO',
dontSetBuildResultOnFailure: false,
dontWaitForConcurrentBuildCompletion: false,
entries: [[
bucket: "${projectName}/${version}",
excludedFile: '',
flatten: false,
gzipFiles: false,
keepForever: false,
managedArtifacts: false,
noUploadOnFailure: true,
selectedRegion: 'eu-west-2',
showDirectlyInBrowser: false,
sourceFile: "${installerFile}",
storageClass: 'STANDARD',
uploadFromSlave: false,
useServerSideEncryption: false]],
pluginFailureResultConstraint: 'FAILURE',
profileName: 'S3PublisherProfile',
userMetadata: []
}
}
}
}
}
}
post {
success {
slackSend channel: "${slackChannel}",
tokenCredentialId: 'slack-integration',
color: "good",
message: "Build Succeeded: ${env.JOB_NAME} ${env.BUILD_NUMBER} : ${env.BUILD_URL}"
}
failure {
slackSend channel: "${slackChannel}",
tokenCredentialId: 'slack-integration',
color: "danger",
message: "Build Failed: ${env.JOB_NAME} ${env.BUILD_NUMBER} : ${env.BUILD_URL}"
}
}
}