-
Notifications
You must be signed in to change notification settings - Fork 7
/
azure-pipelines.yml
313 lines (240 loc) · 9.85 KB
/
azure-pipelines.yml
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
trigger:
- develop
- release/*
- feature/*
pr: none
variables:
- group: Passwords
- group: SoftwareVersions
- group: ConfluencePages
- group: ChangelogIds
parameters:
- name: CordovaVersion
displayName: Plugin version (Only required for Release)
default: "0.0.0"
resources:
repositories:
- repository: sys_kubernetes_templates
type: bitbucket
endpoint: Bitbucket - sistemas
name: situm/sys-kubernetes-templates.git
ref: master
- repository: web_developers
type: bitbucket
endpoint: Bitbucket - sistemas
name: situm/web-developers.git
ref: master
- repository: cordova_sdk_validation
type: bitbucket
endpoint: Bitbucket - sistemas
name: situm/cordova-sdk-validation.git
ref: master
jobs:
- ${{ if or(contains(variables['Build.SourceBranch'], 'feature/'), contains(variables['Build.SourceBranch'],'develop'), ne(variables['Build.Reason'],'Manual')) }}:
- job: Test_iOS
pool:
vmImage: $(macOSVersion)
steps:
- template: azure/common-steps.yaml
- bash: |
echo -e "\n[+] Set xcode version to $(xcodeVersion)"
sudo xcode-select -switch $(xcodeVersion)
echo -e "\n[+] Copy JSON test files \n"
tests/scripts/copy_ios_resources.sh
echo -e "\n[+] Pod install \n"
cd src/ios
pod install
echo -e "\n[+] Execute xcode tests \n"
xcodebuild test -workspace SitumCordovaPlugin.xcworkspace -scheme CordovaLib -destination $(iosSimulator)
if [ $? -ne 0 ];then
echo -e "\n [!] Error with tests....... \n"
exit 1
fi
displayName: Execute Tests
- job: Test_Android
pool:
vmImage: $(ubuntuVersion)
steps:
- template: azure/common-steps.yaml
- bash: |
echo -e "\n[+] Copy JSON test files \n"
tests/scripts/copy_android_resources.sh
echo -e "\n[+] Execute gradle tests \n"
cd src/android
./gradlew test --continue --info
if [ $? -ne 0 ];then
echo -e "\n [!] Error with tests....... \n"
exit 1
fi
displayName: Execute Test
- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: 'src/android/app/build/test-results/*/*.xml'
displayName: Publish test
condition: always()
- job: Test_JS
pool:
vmImage: $(ubuntuVersion)
steps:
- bash: |
cd cordova
echo -e "\n[+] Install npm dependencies \n"
npm install
echo -e "\n[+] Execute npm tests \n"
npm test
displayName: JS Test
- ${{ if contains(variables['Build.SourceBranch'], 'release/') }}:
- job: Generate_Release
pool:
vmImage: $(ubuntuVersion)
steps:
- template: azure/common-steps.yaml
- task: NodeTool@0
inputs:
versionSource: 'spec'
versionSpec: $(nodeVersion)
- ${{ if eq(variables['Build.Reason'],'manual') }}:
- bash: |
if [[ "${{ parameters.CordovaVersion }}" == "0.0.0" ]];then
echo -e "\n[!] IMPORTANT: You don't set the plugin version when you run the release branch and I'm not fortune teller\n"
exit 1
else
echo "##vso[task.setvariable variable=version]$(echo ${{ parameters.CordovaVersion }})"
echo -e "\n[+] I'm a shy step so I don't tell you anything\n"
fi
displayName: Set Cordova Version Manual
- ${{ if ne(variables['Build.Reason'],'manual') }}:
- bash: |
CordovaVersion=$(echo $(Build.SourceBranch) | cut -d "/" -f 4)
echo "##vso[task.setvariable variable=version]$(echo $CordovaVersion)"
echo -e "\n[+] I'm a shy step that only executes where this pipeline run automatic\n"
displayName: Set Cordova Version Automatic
- bash: |
echo -e "\n[+] Installing NPM version $(npmVersion)\n"
npm install -g $(npmVersion)
currentBranch=$(echo $(Build.SourceBranch) | cut -d "/" -f 3,4)
echo "##vso[task.setvariable variable=currentBranch]$(echo $currentBranch)"
echo -e "\n[+] Variables:"
echo -e "\t[+] Plugin version: $(version)"
echo -e "\t[+] NPM CLI version: $(npm --version)"
echo -e "\t[+] Current branch: $currentBranch"
echo -e "\n[+] Setting git remote credentials\n"
if [ -d "cordova" ];then
cd cordova
fi
git remote set-url origin https://situmops:$(github_token)@github.com/$(Build.Repository.Name).git
cat .git/config
displayName: Initial Vars & Configs
- bash: |
cd cordova
echo -e "\n[+] Setting NPM version to $(version)"
npm version $(version) --no-git-tag-version
echo -e "\n[+] Change plugin version in plugin.xml"
sed -i "s/version=\".*\">/version=\"$(version)\">/g" plugin.xml
echo -e "\n[+] Setting git to push NPM version\n"
git config --global user.email "sistemas@situm.es"
git config --global user.name "Situmops"
echo -e "\n[+] Fetch branches \n"
git fetch
echo -e "\n[+] Changing to $(currentBranch)"
git checkout $(currentBranch)
echo -e "\n[+] Add,Commit and Push to $(currentBranch)"
git commit -am "[skip ci] Setting the Cordova version to $(version)"
git push --set-upstream origin $(currentBranch)
git push
displayName: Make changes
- template: azure-templates/publish_release.yml@sys_kubernetes_templates
parameters:
bitbucket:
bitbucket_user: situmops
system: "N/A"
server: "github"
repoFolder: "cordova"
mergeBranches:
- "master"
- "develop"
- bash: |
cd cordova
echo -e "\n[+] Fetch all branches\n"
git fetch
echo -e "\n[+] Checkout and Pull to master branch\n"
git checkout master
git pull origin master
echo -e "\n[+] Configure NPM login"
echo "//registry.npmjs.org/:_authToken=$(NPM_TOKEN)" > ~/.npmrc
echo -e "\n[+] Publish NPM packages"
npm publish --access=public
displayName: NPM publish
- bash: |
cd cordova
echo -e "\n[+] Install dependencies"
npm install
echo -e "\n[+] Generate Documentation\n"
npm run jsdoc
displayName: Generate JSDoc
- template: azure-templates/commit-doc.yaml@sys_kubernetes_templates
parameters:
version: $(version)
docPath: cordova/docs/JSDoc
system: cordova
bitbucket:
bitbucket_user: $(bitbucket_user)
bitbucket_pass: $(bitbucket_pass)
release: "cordova"
- bash: |
if [ -d "cordova" ]; then
cd cordova
fi
echo -e "\n[+] Pull master changes and change to master branch \n"
git fetch
git checkout master
git pull origin master
iossdk=$(grep -oP 'spec="\~> \K[0-9]+\.[0-9]+\.[0-9]+' plugin.xml)
androidsdk=$(grep -oE 'es.situm:situm-sdk:[0-9]+\.[0-9]+\.[0-9]+@aar' src/android/situm.gradle | awk -F'[:@]' '{print $3}')
echo -e "\n[+] Checkout to previous commit\n"
git stash
git checkout HEAD~1
iossdk_old=$(grep -oP 'spec="\~> \K[0-9]+\.[0-9]+\.[0-9]+' plugin.xml)
androidsdk_old=$(grep -oE 'es.situm:situm-sdk:[0-9]+\.[0-9]+\.[0-9]+@aar' src/android/situm.gradle | awk -F'[:@]' '{print $3}')
echo -e "\n[+] Return repository to master branch\n"
git checkout master
echo -e "\n[+] Versions:"
echo -e "\t[+] Cordova SDK: $(version)"
echo -e "\t[+] ANDROID SDK: $androidsdk"
echo -e "\t[+] IOS SDK: $iossdk"
echo -e "\t[+] ANDROID SDK (OLD VERSION): $androidsdk_old"
echo -e "\t[+] IOS SDK (OLD IOS): $iossdk_old"
versions="| *VERSIÓN* | *FECHA* | *ANDROID SDK* | *IOS SDK* |\n|$(version)|$(date +"%d/%m/%Y")|"
if [ "$androidsdk" != "$androidsdk_old" ];then
versions="$versions *$androidsdk* |"
android_changelog_version=$androidsdk
else
android_changelog_version="0.0.0"
versions="$versions $androidsdk|"
fi
if [ "$iossdk" != "$iossdk_old" ];then
versions="$versions *$iossdk*|"
ios_changelog_version=$iossdk
else
ios_changelog_version="0.0.0"
versions="$versions $iossdk|"
fi
echo "##vso[task.setvariable variable=versions]$(echo $versions)"
echo "##vso[task.setvariable variable=android_changelog_version]$(echo $android_changelog_version)"
echo "##vso[task.setvariable variable=ios_changelog_version]$(echo $ios_changelog_version)"
displayName: Get Versions
- template: azure-templates/publish-changelog.yaml@sys_kubernetes_templates
parameters:
changelogId: $(Cordova_Changelog_id)
android_changelog_version: $(android_changelog_version)
ios_changelog_version: $(ios_changelog_version)
- template: azure-templates/release-table.yaml@sys_kubernetes_templates
parameters:
versions: $(versions)
releaseTable: CORDOVA_SDK_TABLE
confluence_release_page: $(CORDOVA_SDK_TABLE)
confluence_release_page_title: "SDK Automatic Release Table - Cordova Plugin"
bitbucket:
bitbucket_user: $(bitbucket_user)
bitbucket_pass: $(bitbucket_pass)