This repository has been archived by the owner on Jun 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Jenkinsfile
173 lines (168 loc) · 6.64 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
#!/bin/env groovy
@Library('cliqz-shared-library@vagrant') _
node('mac-mini-ios') {
writeFile file: 'Vagrantfile', text: '''
Vagrant.configure("2") do |config|
config.vm.box = "ios-xcode9.3"
config.vm.define "priosx93" do |prvm|
prvm.vm.hostname = ENV['NODE_ID']
prvm.vm.boot_timeout = 900
prvm.vm.provider "vmware_fusion" do |v|
v.name = ENV['NODE_ID']
v.whitelist_verified = true
v.gui = false
v.memory = ENV["NODE_MEMORY"]
v.cpus = ENV["NODE_CPU_COUNT"]
v.vmx["remotedisplay.vnc.enabled"] = "TRUE"
v.vmx["RemoteDisplay.vnc.port"] = ENV["NODE_VNC_PORT"]
v.vmx["ethernet0.pcislotnumber"] = "33"
end
prvm.vm.provision "shell", privileged: false, run: "always", inline: <<-SHELL#!/bin/bash -l
set -e
set -x
rm -f agent.jar
curl -LO #{ENV['JENKINS_URL']}/jnlpJars/agent.jar
nohup java -jar agent.jar -jnlpUrl #{ENV['JENKINS_URL']}/computer/#{ENV['NODE_ID']}/slave-agent.jnlp -secret #{ENV['NODE_SECRET']} &
SHELL
end
end
'''
def jobStatus = 'FAIL'
vagrant.inside(
'Vagrantfile',
'/jenkins',
4, // CPU
8000, // MEMORY
12000, // VNC port
false, // rebuild image
) {
nodeId ->
node(nodeId) {
try {
stage("Checkout") {
checkout scm
dir('cliqz-mobile-tests'){
git branch:'master',
credentialsId: 'cliqz-oss-ci',
url: 'https://github.com/cliqz-oss/cliqz-mobile-tests.git'
}
}
stage('Prepare Environment') {
sh '''#!/bin/bash -l
set -e
set -x
brew update
brew list carthage &>/dev/null || brew install carthage
brew list python2 &>/dev/null || brew install python2
sudo -H python2 -m ensurepip
chmod 0755 cliqz-mobile-tests/requirements.txt
sudo -H python2 -m pip install -vvvr cliqz-mobile-tests/requirements.txt
'''
}
stage('Setup Build Environment') {
sh '''#!/bin/bash -l
set -e
set -x
carthage bootstrap --verbose --platform ios --color auto --cache-builds
npm cache clean --force
'''
try {
sh '''#!/bin/bash -l
set -e
set -x
npm install
'''
} catch(e) {
sh '''#!/bin/bash -l
set -e
set -x
npm install
'''
}
sh '''#!/bin/bash -l
set -e
set -x
npm run build
pod install --repo-update
npm run bundle
'''
}
stage('Build') {
timeout(60) {
sh '''#!/bin/bash -l
set -e
xcodebuild \
-workspace Client.xcworkspace \
-scheme "Fennec" \
-sdk iphonesimulator \
-destination "platform=iOS Simulator,OS=11.3,id=8A112602-53F8-4996-A58A-FC65665635EB" \
OTHER_SWIFT_FLAGS='$(value) -DAUTOMATION' \
ONLY_ACTIVE_ARCH=NO \
-derivedDataPath clean build test
'''
}
}
stage('Run Tests') {
withEnv([
'platformName=ios',
'udid=8A112602-53F8-4996-A58A-FC65665635EB',
'deviceName=iPhone 6s',
'platformVersion=11.3',
'bundleID=com.cliqz.ios.newCliqz',
"MODULE=testCompleteSuite",
"TEST=CompleteSuite",
"TEST_TYPE=smoke"
]) {
timeout(60) {
sh '''#!/bin/bash -l
set -x
set -e
npm run appium
sleep 15
python cliqz-mobile-tests/testRunner.py
'''
}
}
}
jobStatus = 'PASS'
}
catch(all) {
jobStatus = 'FAIL'
}
finally {
stage('Upload Results') {
archiveTestResults()
}
stage('Cleanup') {
sh '''#!/bin/bash -l
set -x
kill $(ps -A | grep -m1 appium | awk '{print \$1}')
rm -rf *.log\
cliqz-mobile-tests \
screenshots \
screenshots.zip \
test-reports
xcrun simctl boot 8A112602-53F8-4996-A58A-FC65665635EB || true
xcrun simctl uninstall 8A112602-53F8-4996-A58A-FC65665635EB com.cliqz.ios.newCliqz
xcrun simctl uninstall 8A112602-53F8-4996-A58A-FC65665635EB com.apple.test.WebDriverAgentRunner-Runner
xcrun simctl uninstall 8A112602-53F8-4996-A58A-FC65665635EB com.apple.test.AppiumTests-Runner
sleep 15
xcrun simctl shutdown 8A112602-53F8-4996-A58A-FC65665635EB || true
'''
}
}
}
}
if (jobStatus == 'FAIL') {
error "Something Failed. Check the above logs."
}
}
def archiveTestResults() {
try {
archiveArtifacts allowEmptyArchive: true, artifacts: '*.log'
junit 'test-reports/*.xml'
zip archive: true, dir: 'screenshots', glob: '', zipFile: 'screenshots.zip'
} catch(e) {
print e
}
}