Issue
When i run the test cases from the studio, all the test cases are passing without any issue. But it's failing in jenkins due to the following exception
org.apache.tools.ant.BuildException
Caused by: org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException
When i looked into internet i got to know that this is happening because the jenkins blocks internet, and if it's not able to download the dependancy it will fail with this expection. But when i contacted the jenkins it team, they informed that if we are passing proxy in config it will always give internet.That i am passing already as follows.
sh "export ANDROID_HOME=/var/buildtools/android && export JAVA_HOME=/usr/java/jdk1.8.0_161 && export PATH=$PATH:/var/buildtools/gradle-4.10.1/bin && gradle -Dhttp.proxyHost=$http_proxy -Dhttp.proxyPort=$http_proxy_port -Dhttps.proxyHost=$https_proxy -Dhttps.proxyPort=$https_proxy_port assembleRelease codeCoverageReport"
So what can be the issue here?
Solution
This is an issue with roboelectric, which tries to download some dependancies at runtime and the jenkins will block it because the proxy what we are passing is not applicable, if it's downloading at runtime. So we have to give the proxy for unit tests as follows
testOptions {
unitTests.all {
systemProperty 'http.proxyHost', 'xxx.xx.xxx.xxx'
systemProperty 'http.proxyPort', 'xxxx'
systemProperty 'https.proxyHost', 'xxx.xx.xxx.xxx'
systemProperty 'https.proxyPort', 'xxxx'
}
unitTests{
returnDefaultValues = true
includeAndroidResources = true
}
}
Have to add this inside android{...}
which solved the issue.
Answered By - Jinesh Francis
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.