1
+ # Maven
2
+
3
+ trigger :
4
+ - master
5
+
6
+ pool :
7
+ vmImage : ' macOS 10.14'
8
+
9
+ variables :
10
+ ANDROID_EMU_NAME : test
11
+ ANDROID_EMU_ABI : x86
12
+ ANDROID_EMU_TARGET : android-28
13
+ ANDROID_EMU_TAG : google_apis
14
+ XCODE_VERSION : 10.2
15
+ IOS_PLATFORM_VERSION : 12.2
16
+ IOS_DEVICE_NAME : iPhone X
17
+ steps :
18
+
19
+ - task : SonarCloudPrepare@1
20
+ displayName : ' Prepare SonarCloud analysis'
21
+ inputs :
22
+ SonarCloud : ' SonarCloud'
23
+ organization : ' aqualityautomation'
24
+ scannerMode : ' CLI'
25
+ configMode : ' file'
26
+ extraProperties : |
27
+ sonar.coverage.exclusions=**/**
28
+
29
+ - task : Maven@3
30
+ displayName : ' Compile project'
31
+ inputs :
32
+ mavenPomFile : ' pom.xml'
33
+ goals : ' clean compile'
34
+ publishJUnitResults : true
35
+ testResultsFiles : ' **/surefire-reports/TEST-*.xml'
36
+ javaHomeOption : ' JDKVersion'
37
+ mavenVersionOption : ' Default'
38
+ mavenAuthenticateFeed : false
39
+ effectivePomSkip : false
40
+ sonarQubeRunAnalysis : false
41
+ continueOnError : true
42
+
43
+ - task : SonarCloudAnalyze@1
44
+ displayName : ' Run SonarCloud code analysis'
45
+ continueOnError : true
46
+
47
+ - task : SonarCloudPublish@1
48
+ displayName : ' Publish SonarCloud quality gate results'
49
+ continueOnError : true
50
+
51
+ - task : NodeTool@0
52
+ displayName : ' Install Node.js tool to setup Appium and emulators'
53
+ inputs :
54
+ versionSpec : ' 11.15.0'
55
+
56
+ - script : |
57
+ echo "Configuring Environment"
58
+ echo $JAVA_HOME
59
+ ls /Library/Java/JavaVirtualMachines/
60
+
61
+ ls $ANDROID_HOME/build-tools/
62
+ export PATH=$PATH:$JAVA_HOME/bin
63
+
64
+ echo export "ANDROID_HOME=\$ANDROID_HOME" >> ~/.bash_profile
65
+ export PATH=$PATH:$ANDROID_HOME
66
+
67
+ mvn -version
68
+ echo $ANDROID_HOME
69
+ echo $JAVA_HOME
70
+ echo $PATH
71
+
72
+ echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install 'system-images;$(ANDROID_EMU_TARGET);$(ANDROID_EMU_TAG);$(ANDROID_EMU_ABI)'
73
+ echo "no" | $ANDROID_HOME/tools/bin/avdmanager create avd -n "$(ANDROID_EMU_NAME)" -k 'system-images;$(ANDROID_EMU_TARGET);$(ANDROID_EMU_TAG);$(ANDROID_EMU_ABI)' --force
74
+ echo $ANDROID_HOME/emulator/emulator -list-avds
75
+
76
+ echo "Starting emulator"
77
+ nohup $ANDROID_HOME/emulator/emulator -avd "$(ANDROID_EMU_NAME)" -no-snapshot > /dev/null 2>&1 &
78
+ $ANDROID_HOME/platform-tools/adb wait-for-device
79
+ while [[ $? -ne 0 ]]; do sleep 1; $ANDROID_HOME/platform-tools/adb shell pm list packages; done;
80
+ $ANDROID_HOME/platform-tools/adb devices
81
+ echo "Emulator started"
82
+
83
+
84
+ echo "Installing Appium"
85
+ node --version
86
+
87
+ npm list --depth 0
88
+
89
+ # --chromedriver-skip-install
90
+ ln -fs /usr/local/lib/node_modules/appium/build/lib/main.js /usr/local/bin/appium
91
+ chmod +x /usr/local/bin/appium
92
+ export PATH=$PATH:/usr/local/bin/appium
93
+
94
+ echo "Installing and Running Appium doctor"
95
+ npm install -g appium-doctor
96
+ ln -fs /usr/local/lib/node_modules/appium-doctor/appium-doctor.js /usr/local/bin/appium-doctor
97
+ chmod +x /usr/local/bin/appium-doctor
98
+ export PATH=$PATH:/usr/local/bin/appium-doctor
99
+
100
+ npm list --depth 0
101
+
102
+ appium --version
103
+ appium-doctor
104
+
105
+ #sudo xcode-select -s /Applications/Xcode_$(XCODE_VERSION).app/Contents/Developer
106
+ #xcrun simctl list
107
+
108
+ appium --allow-insecure chromedriver_autodownload &
109
+ echo "Appium server started"
110
+
111
+ - task : Maven@3
112
+ displayName : ' Run tests'
113
+ inputs :
114
+ mavenPomFile : ' pom.xml'
115
+ goals : ' test'
116
+ publishJUnitResults : true
117
+ testResultsFiles : ' **/surefire-reports/TEST-*.xml'
118
+ javaHomeOption : ' JDKVersion'
119
+ mavenVersionOption : ' Default'
120
+ mavenAuthenticateFeed : false
121
+ effectivePomSkip : false
122
+ sonarQubeRunAnalysis : false
123
+ continueOnError : true
124
+
125
+ - task : CopyFiles@2
126
+ displayName : ' Copy failure screenshots and test logs'
127
+ inputs :
128
+ SourceFolder : ' $(Build.SourcesDirectory)/target'
129
+ Contents : |
130
+ surefire-reports/failure_screenshots/*.png
131
+ log/*.log
132
+ TargetFolder : ' $(Build.ArtifactStagingDirectory)'
133
+
134
+ - task : PublishBuildArtifacts@1
135
+ displayName : ' Publish copied artifacts'
136
+ inputs :
137
+ PathtoPublish : ' $(Build.ArtifactStagingDirectory)'
138
+ ArtifactName : ' drop'
139
+ publishLocation : ' Container'
0 commit comments