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