why caching is not working in this code from gitlab-ci? - java

Given the code below, extracted from my project's .gitlab-ci.xml, I would like to know why the cache is not working.
Notice that there are three stages related to the package_install stage, one for each environment. In each step, a java/maven and an angular project is packaged. Do I need to call the cache or reference the cache within each step? Or is there something else wrong?
image: XXX
stages:
- package_install
- xxx
variables:
PROJECT_NAME_BACK: contaspublicas-backend
PROJECT_NAME_FRONT: contaspublicas-frontend
cache:
- key: $PROJECT_NAME_BACK
paths:
- ${CI_PROJECT_DIR}/.m2/repository/
- key: $PROJECT_NAME_FRONT
paths:
- node_modules
package_install_testes: #Skips testes, pois serão executados na fase de teste
stage: package_install
script:
- cd $PROJECT_NAME_BACK
- mvn -Ptest install -DskipTests=true
- cd ..
- cd $PROJECT_NAME_FRONT
- npm ci
- ng build --configuration test --base-href .
- cd dist/contaspublicasng
- jar cvf contaspublicasng.war .
artifacts:
paths:
- contaspublicas-backend/target/*.war
- contaspublicas-backend/target/*.jar
- $PROJECT_NAME_FRONT/dist/contaspublicasng/contaspublicasng.war
except:
- main
- homolog
package_install_homolog: #Skips testes, pois serão executados na fase de teste
stage: package_install
script:
- cd $PROJECT_NAME_BACK
- mvn -Phml install -DskipTests=true
- cd ..
- cd $PROJECT_NAME_FRONT
- npm ci
- ng build --configuration hml --base-href .
- cd dist/contaspublicasng
- jar cvf contaspublicasng.war .
artifacts:
paths:
- contaspublicas-backend/target/*.war
- contaspublicas-backend/target/*.jar
- $PROJECT_NAME_FRONT/dist/contaspublicasng/contaspublicasng.war
only:
- homolog
package_install_main: #Skips testes, pois serão executados na fase de teste
stage: package_install
script:
- cd $PROJECT_NAME_BACK
- mvn versions:set -DremoveSnapshot
- mvn -Pprod install -DskipTests=true
- cd ..
#- echo versao=$(ls starbackend/target/ | grep war | cut -d '-' -f 2 | sed -e 's/\.war$//') >> build.env
- echo VERSAO=$(ls $PROJECT_NAME_BACK/target/ | find . -type f -name \*.war | cut -d '-' -f 2 | sed -e 's/\.war$//') >> build.env
- cd $PROJECT_NAME_FRONT
- npm ci
- ng build --configuration prod --base-href .
- cd dist/contaspublicasng
- jar cvf contaspublicasng.war .
artifacts:
paths:
- contaspublicas-backend/target/*.war
- contaspublicas-backend/target/*.jar
- $PROJECT_NAME_FRONT/dist/contaspublicasng/contaspublicasng.war
reports:
dotenv: build.env
only:
- main
The way it is the cache does not work in the pipeline

You need to tell maven to use directory configured there:
cache:
- key: $PROJECT_NAME_BACK
paths:
- ${CI_PROJECT_DIR}/.m2/repository/
smth. like:
variables:
MAVEN_OPTS: "-Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository"

Related

SonarQube shows less coverage for code when java 8 is used

I am running sonar on my spring-boot-based service, previously coverage was 75%, but after migrating sonar runner to java 11, My code coverage is 15%. I tested in some other services when I run tests with jdk11 image and sonar using JDK 11, I get proper coverage, but in this service because of some issue I don't want to run tests using JDK 11, what might be missing?
Configuration giving proper coverage (Note this is a different service)
.test: &test
stage: test
image: maven:3.8.1-openjdk-11-slim
services:
- mongo
- docker:dind
script:
- mvn test -Dspring.profiles.active=$PROFILE
tags:
- build-devops
artifacts:
paths:
- target/jacoco.exec
- target/spotbugsXml.xml
- target/dependency-check-report.xml
- target/dependency-check-report.html
- target/checkstyle-result.xml
sonarqube:
stage: sonar
image: maven:3.8.1-openjdk-11-slim
script:
- mvn -q -U -B verify --settings settings.xml sonar:sonar -DskipTests=true -Dsonar.host.url=$SONAR_URL -Dsonar.login=$SONAR_LOGIN
Configuration of service having issue
.test: &test
stage: test
image: maven:3.8.1-openjdk-8-slim
services:
- mongo
- docker:dind
script:
- mvn test -Dspring.profiles.active=local
- mvn test -Dspring.profiles.active=central
tags:
- build-devops
artifacts:
paths:
- target/jacoco.exec
- target/spotbugsXml.xml
- target/dependency-check-report.xml
- target/dependency-check-report.html
- target/checkstyle-result.xml
sonarqube:
stage: sonar
image: maven:3.8.1-openjdk-11-slim
script:
- mvn -q -U -B verify sonar:sonar --settings settings.xml -DskipTests=true -Dsonar.host.url=$SONAR_URL -Dsonar.login=$SONAR_LOGIN

DB connection during integration tests works on local, but not working on Google Cloud Build

I'm deploying Java 11 REST API to GKE using GitHub, Gradle, and Docker.
The following errors are only happened on Google Cloud Build, not on the local environment. According to the error, it seems the app can't find the DB server(Google Cloud SQL) from Google Cloud Build. I tried both public and private IP, but the results were the same:
...
Step #0 - "Build": 2021-03-11 04:12:04.644 INFO 115 --- [ Test worker] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
Step #0 - "Build": 2021-03-11 04:12:35.855 ERROR 115 --- [ Test worker] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception during pool initialization.
Step #0 - "Build":
Step #0 - "Build": com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
Step #0 - "Build":
Step #0 - "Build": The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
...
Step #0 - "Build": Caused by: java.net.SocketTimeoutException: connect timed out
...
This happened after I added integration tests. The app deployed successfully after I removed the tests. So, I can remove the integration tests to avoid this issue. The thing is, I want to keep the tests if possible because there are things that we can't test with unit tests.
This is the Dockerfile I'm using for deployments to GKE. RUN gradle build --no-daemon -i --stacktrace is where the error occurs during the test task:
ARG APP_NAME=test-api
ARG GRADLE_USER_HOME_PATH=/home/gradle/cache_home/
#cache dependencies to reduce downloads
FROM gradle:6.8-jdk11 AS cache
ARG APP_NAME
ARG GRADLE_USER_HOME_PATH
WORKDIR /${APP_NAME}/
RUN mkdir -p ${GRADLE_USER_HOME_PATH}
ENV GRADLE_USER_HOME ${GRADLE_USER_HOME_PATH}
COPY --chown=gradle:gradle build.gradle /${APP_NAME}/
RUN gradle clean build --no-daemon -i --stacktrace -x bootJar
#build
FROM gradle:6.8-jdk11 AS build
ARG APP_NAME
ARG GRADLE_USER_HOME_PATH
WORKDIR /${APP_NAME}/
#Copies cached dependencies
COPY --from=cache ${GRADLE_USER_HOME_PATH} /home/gradle/.gradle/
#Copies the Java source code inside the container
COPY --chown=gradle:gradle . /${APP_NAME}/
#Compiles the code and runs unit tests (with Gradle build)
RUN gradle build --no-daemon -i --stacktrace
#Discards the Gradle image with all the compiled classes/unit test results etc.
#Starts again from the JRE image and copies only the JAR file created before
FROM openjdk:11-jre-slim
ARG APP_NAME
COPY --from=build /${APP_NAME}/build/libs/${APP_NAME}.jar /${APP_NAME}/${APP_NAME}.jar
ENTRYPOINT ["java","-jar","/test-api/test-api.jar"]
How to implement integration tests that using DB to GKE? Or maybe I need to change my approach?
I managed to solve the problem referencing this Q&A: Run node.js database migrations on Google Cloud SQL during Google Cloud Build
I had to add 2 steps(Cloud SQL Proxy and Test) on cloudbuild.yaml to use Cloud SQL Proxy. The other steps were auto-generated by GKE:
steps:
- name: gradle:6.8.3-jdk11
entrypoint: sh
args:
- '-c'
- |-
apt-get update && apt-get install -y wget \
&& wget "https://storage.googleapis.com/cloudsql-proxy/v1.21.0/cloud_sql_proxy.linux.amd64" -O cloud_sql_proxy \
&& chmod +x cloud_sql_proxy \
|| exit 1
id: Cloud SQL Proxy
- name: gradle:6.8.3-jdk11
entrypoint: sh
args:
- '-c'
- |-
(./cloud_sql_proxy -instances=<CONNECTION_NAME>=tcp:<PORT> & sleep 2) \
&& gradle test --no-daemon -i --stacktrace \
|| exit 1
id: Test
- name: gcr.io/cloud-builders/docker
args:
- build
- '-t'
- '$_IMAGE_NAME:$COMMIT_SHA'
- .
- '-f'
- $_DOCKERFILE_NAME
dir: $_DOCKERFILE_DIR
id: Build
- name: gcr.io/cloud-builders/docker
args:
- push
- '$_IMAGE_NAME:$COMMIT_SHA'
id: Push
- name: gcr.io/cloud-builders/gke-deploy
args:
- prepare
- '--filename=$_K8S_YAML_PATH'
- '--image=$_IMAGE_NAME:$COMMIT_SHA'
- '--app=$_K8S_APP_NAME'
- '--version=$COMMIT_SHA'
- '--namespace=$_K8S_NAMESPACE'
- '--label=$_K8S_LABELS'
- '--annotation=$_K8S_ANNOTATIONS,gcb-build-id=$BUILD_ID'
- '--create-application-cr'
- >-
--links="Build
details=https://console.cloud.google.com/cloud-build/builds/$BUILD_ID?project=$PROJECT_ID"
- '--output=output'
id: Prepare deploy
- name: gcr.io/cloud-builders/gsutil
args:
- '-c'
- |-
if [ "$_OUTPUT_BUCKET_PATH" != "" ]
then
gsutil cp -r output/suggested gs://$_OUTPUT_BUCKET_PATH/config/$_K8S_APP_NAME/$BUILD_ID/suggested
gsutil cp -r output/expanded gs://$_OUTPUT_BUCKET_PATH/config/$_K8S_APP_NAME/$BUILD_ID/expanded
fi
id: Save configs
entrypoint: sh
- name: gcr.io/cloud-builders/gke-deploy
args:
- apply
- '--filename=output/expanded'
- '--cluster=$_GKE_CLUSTER'
- '--location=$_GKE_LOCATION'
- '--namespace=$_K8S_NAMESPACE'
id: Apply deploy
...
And Dockerfile:
ARG APP_NAME=test-api
ARG APP_HOME=/test-api
FROM openjdk:11-jdk-slim AS build
USER root
ARG APP_HOME
WORKDIR ${APP_HOME}/
COPY . .
# test is performed from Test step from cloudbuild.yaml
RUN ./gradlew build --no-daemon -i --stacktrace -x test
FROM openjdk:11-jdk-slim
ARG APP_NAME
ARG APP_HOME
WORKDIR ${APP_HOME}/
COPY --from=build ${APP_HOME}/build/libs/${APP_NAME}.jar ./${APP_NAME}.jar
EXPOSE 8080
ENTRYPOINT ["java","-jar","/test-api/test-api.jar"]
While I solved the questioned problem, this script has a little problem: there will be 2 separate Gradle dependencies downloads(Test and Build). I couldn't manage to use Cloud SQL Proxy on gcr.io/cloud-builders/docker, so I workaround by using the Test step instead of the Build step. Maybe this can be solved using either docker run --network="host" or host.docker.internal, but I didn't try.

Google Cloud Debugger can't find Spring Boot web app deployed as Cloud Run service

I followed the guide (https://cloud.google.com/debugger/docs/setup/java#cloud-run) to setup the cloud debugger for my cloud run services. Everything looks like it should work. However the debugger UI tells me it can not find any application.
However I did everything that was suugested in the documentation
Source code is in Source Repositories
Cloud Build triggers on master push
I download the cdbg-java-agent.so
I run the java application with the -agentpath option
Cloud Run service is being deployed via cloudbuild.yaml
Cloud Run service starts healthy and works
However as you can see in the screenshot my application can not be found after successful deployment.
Here are some details of my configuration:
Spring Boot v2.4.2
Kotlin 1.4.21
This is my Dockerfile
FROM gradle:6.7.0-jdk14 as build
USER root
WORKDIR /dist
ADD . /dist
RUN gradle assemble
FROM alpine as agent
USER root
WORKDIR /agent
RUN wget -qO- https://storage.googleapis.com/cloud-debugger/compute-java/debian-wheezy/cdbg_java_agent_gce.tar.gz | tar xvz
FROM openjdk:14-slim
WORKDIR /app
COPY --from=agent /agent/cdbg_java_agent.so agent.so
COPY --from=build /dist/build/libs/user-service.jar app.jar
EXPOSE 8080
CMD ["java", "-agentpath:/app/agent.so", "-Dcom.google.cdbg.breakpoints.enable_canary=false", "-jar", "app.jar"]
Here is the docker build output
Deploying '<unknown> Dockerfile: Dockerfile'...
Building image...
Preparing build context archive...
[==================================================>]1855/1855 files
Done
Sending build context to Docker daemon...
[==================================================>] 76.19MB
Done
Step 1/15 : FROM gradle:6.7.0-jdk14 as build
---> 5af4d25725b2
Step 2/15 : USER root
---> Using cache
---> c97e9145e3e1
Step 3/15 : WORKDIR /dist
---> Using cache
---> 468fff36a2e7
Step 4/15 : ADD . /dist
---> c435bd2ffde9
Step 5/15 : RUN gradle assemble
---> Running in 70f5c69b7dde
Welcome to Gradle 6.7!
Here are the highlights of this release:
- File system watching is ready for production use
- Declare the version of Java your build requires
- Java 15 support
For more details see https://docs.gradle.org/6.7/release-notes.html
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :compileKotlin
> Task :compileJava NO-SOURCE
> Task :processResources
> Task :classes
> Task :bootJarMainClassName
> Task :bootJar
> Task :inspectClassesForKotlinIC
> Task :jar SKIPPED
> Task :assemble
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 1m 48s
5 actionable tasks: 5 executed
Removing intermediate container 70f5c69b7dde
---> 5bbd9485f873
Step 6/15 : FROM alpine as agent
---> 28f6e2705743
Step 7/15 : USER root
---> Using cache
---> 4a0572e8ff4a
Step 8/15 : WORKDIR /agent
---> Using cache
---> 0374735af05d
Step 9/15 : RUN wget -qO- https://storage.googleapis.com/cloud-debugger/compute-java/debian-wheezy/cdbg_java_agent_gce.tar.gz | tar xvz
---> Using cache
---> ef141a7d5acc
Step 10/15 : FROM openjdk:14-slim
---> 38fca30874ab
Step 11/15 : WORKDIR /app
---> Using cache
---> 4dd576d38d65
Step 12/15 : COPY --from=agent /agent/cdbg_java_agent.so agent.so
---> Using cache
---> ff5fc93d2d5e
Step 13/15 : COPY --from=build /dist/build/libs/user-service.jar app.jar
---> 4b009124345f
Step 14/15 : EXPOSE 8080
---> Running in 99f71fb86534
Removing intermediate container 99f71fb86534
---> 38fcd9d00999
Step 15/15 : CMD ["java", "-agentpath:/app/agent.so", "-Dcom.google.cdbg.breakpoints.enable_canary=false", "-jar", "app.jar"]
---> Running in 309f35aed48f
Removing intermediate container 309f35aed48f
---> 43757d33b2ee
Successfully built 43757d33b2ee
Existing container found: 94d3fab4505461e8e694b61909ba1f7d827d8f7078b4dd8d1d36d4c4e0a0ac08, removing...
Creating container...
Container Id: b99675b5f6c00a0e5bec76999db04abf92eab29d257ee887bcea123a02789850
Container name: '/quirky_stonebraker'
Attaching to container '/quirky_stonebraker'...
Starting container '/quirky_stonebraker'
'<unknown> Dockerfile: Dockerfile' has been deployed successfully.
The container runs fine as already stated with the mentioned deployed cloud run service.
So I am out of ideas on what to do to make this work. I hope anybody can help me out here
I also add my cloudbuild.yaml in case that is relevant
steps:
- name: 'gradle:6.8.3-jdk11'
entrypoint: 'gradle'
args: [ 'check', '-x', 'test']
- name: 'gradle:6.8.3-jdk11'
entrypoint: 'gradle'
args: [ 'test']
- name: 'gradle:6.8.3-jdk11'
entrypoint: 'gradle'
args: [ 'integration-test']
- name: 'gcr.io/cloud-builders/docker'
args: [ 'build', '-t', 'eu.gcr.io/$PROJECT_ID/user-service:$BUILD_ID', '.' ]
- name: 'gcr.io/cloud-builders/docker'
args: [ 'push', 'eu.gcr.io/$PROJECT_ID/user-service:$BUILD_ID' ]
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: gcloud
args:
- 'alpha'
- 'run'
- 'deploy'
- 'user-service'
- '--image=eu.gcr.io/$PROJECT_ID/user-service:$BUILD_ID'
- '--concurrency=10'
- '--cpu=1'
- '--memory=512Mi'
- '--region=europe-west3'
- '--max-instances=2'
- '--platform=managed'
- '--port=8080'
- '--timeout=3000'
- '--set-env-vars=SQL_CONNECTION=10.28.96.3, SQL_USER=test, SQL_PASSWORD=test'
- '--set-env-vars=AUTH0_DOMAIN=prototype.eu.auth0.com, AUTH0_CLIENT_ID=123, AUTH0_CLIENT_SECRET=123'
- '--set-env-vars=^#^SPRING_PROFILES_ACTIVE=prod'
- '--allow-unauthenticated'
- '--ingress=internal'
- '--vpc-connector=cloud-run'
- '--vpc-egress=private-ranges-only'
- '--set-cloudsql-instances=$PROJECT_ID:europe-west1:prototype'
images:
- 'eu.gcr.io/$PROJECT_ID/user-service:$BUILD_ID'
timeout: 3000s
If you look what's inside the zipped agent file, you'll notice that there's a few files in it called:
cdbg_java_agent.so
cdbg_java_agent_internals.jar
version.txt
You're getting this problem because you missed to copy the internals.jar file to /app dir. The shared object file has a dependency and that can explain why users are instructed to create a separate directory for the Debugger.
To fix it on this case, add the missing file on to your Dockerfile like this:
COPY --from=agent /agent/cdbg_java_agent.so agent.so
COPY --from=agent /agent/cdbg_java_agent_internals.jar cdbg_java_agent_internals.jar
COPY --from=build /dist/build/libs/user-service.jar app.jar
Then wait for approx. ~5 minutes until your service appears on the Debugger. Note that the source code will not appear automatically unless it's located on a Git repo. For that you have to select the source code manually.

How to configure continuous integration for aws lambda with java using the services of aws aws-codebuild, codedeploy, cloudformation

I am implementing a lambda function with the tool of continuous integrations of aws . CodeSource , CodeBuild CodePipeLine.
After set up all, when i test the lambda the result is
{
"errorMessage": "Class not found: com.ad.client.App",
"errorType": "java.lang.ClassNotFoundException"
}
Class not found: com.ad.client.App: java.lang.ClassNotFoundException
java.lang.ClassNotFoundException: com.ad.client.App
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
All stage of Pipeline are succeeded(Source , Build , Deploy)
If a load the jar directly in the lambda console the result is the correct
I review the log of the build and found this:
[Container] 2019/06/13 13:09:38 Running command echo THE PATH WORK IS !!!
THE PATH WORK IS !!!
[Container] 2019/06/13 13:09:38 Running command pwd
/codebuild/output/src748698927/src
[Container] 2019/06/13 13:09:38 Running command echo The list of file is !!
The list of file is !!
[Container] 2019/06/13 13:09:38 Running command ls
Readme.md
buildspec.yml
dependency-reduced-pom.xml
ftc-client.iml
outputtemplate.yaml
pom.xml
src
target
template.yaml
[Container] 2019/06/13 13:09:38 Running command echo CODE BUILD SRC DIRECTORY
CODE BUILD SRC DIRECTORY
[Container] 2019/06/13 13:09:38 Running command echo $CODEBUILD_SRC_DIR
/codebuild/output/src748698927/src
INFO] skip non existing resourceDirectory /codebuild/output/src748698927/src/src/main/resources
In some portion of code show me that the path src is duplicated, i don't know if it has something to related with the problem
My config files are:
template.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Ftc-client
Resources:
FtcClientFunction:
Type: AWS::Serverless::Function
Properties:
Handler: com.ad.client.App::handleRequest
Runtime: java8
CodeUri: ./
Events:
MyFtcClientApi:
Type: Api
Properties:
Path: /client
Method: GET
buildspec.yml
version: 0.2
phases:
install:
runtime-versions:
java: openjdk8
build:
commands:
- echo Build started on `date`
- mvn test
- export BUCKET=my-bucket-for-test
- aws cloudformation package --template-file template.yaml --s3-bucket $BUCKET --output-template-file outputtemplate.yaml
finally:
- echo THE PATH WORK IS !!!
- pwd
- echo The list of file is !!
- ls
- echo CODE BUILD SRC DIRECTORY
- echo $CODEBUILD_SRC_DIR
post_build:
commands:
- echo Build completed on `date`
- mvn package
artifacts:
files:
- target/ftc-client-1.0-SNAPSHOT.jar
- template.yaml
- outputtemplate.yaml
discard-paths: yes
The source code structure is :
/fclient/src/main/java/com/ad/App.java
/tclient/buildspec.yml
/fclient/pom.xml
/fclient/template.yaml
I want to make this but with Java : https://docs.aws.amazon.com/lambda/latest/dg/build-pipeline.html
thank for everyone whom can give me a cue
This is the solution - it was necessary to unzip the jar in root of my code:
version: 0.2
phases:
install:
runtime-versions:
java: openjdk8
pre_build:
commands:
- echo Test started on `date`
- mvn clean compile test
build:
commands:
- echo Build started on `date`
- export BUCKET=my-bucket-for-test
- mvn package shade:shade
- mv target/ftc-client-1.0-SNAPSHOT.jar
- unzip ftc-client-1.0-SNAPSHOT.jar
- rm -rf target tst src buildspec.yml pom.xml ftc-client-1.0-SNAPSHOT.jar
- aws cloudformation package --template-file template.yaml --s3-bucket $BUCKET --output-template-file outputtemplate.yaml
post_build:
commands:
- echo Build completed on `date` !!!
artifacts:
files:
- target/ftc-client-1.0-SNAPSHOT.jar
- template.yaml
- outputtemplate.yaml
https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html

Travis CI - android build failed. No connected devices error

Trying to get started with Travis CI for my Android projects but Travis still failing while build my android project.
Reason:
:app:connectedDebugAndroidTest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:connectedDebugAndroidTest'.
> com.android.builder.testing.api.DeviceException: No connected devices!
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Link to travis:
https://travis-ci.org/hypeapps/Episodie/builds/158706530
.travis.yml:
language: android
jdk:
- oraclejdk8
before_install:
- chmod +x gradlew
env:
global:
- ANDROID_API_LEVEL=24
- EMULATOR_API_LEVEL=21
- ANDROID_BUILD_TOOLS_VERSION=24.0.1
- ANDROID_ABI=google_apis/armeabi-v7a
- ADB_INSTALL_TIMEOUT=20 # minutes (2 minutes by default)
android:
components:
- tools
- tools
- platform-tools
- build-tools-$ANDROID_BUILD_TOOLS_VERSION
- android-$ANDROID_API_LEVEL
- android-$EMULATOR_API_LEVEL
- extra
- add-on
- extra-google-m2repository
- extra-android-m2repository
# Google Play Services
- extra-google-google_play_services
# Support library
- extra-android-support
- addon-google_apis-google-$ANDROID_API_LEVEL
- addon-google_apis-google-$EMULATOR_API_LEVEL
- sys-img-armeabi-v7a-addon-google_apis-google-$ANDROID_API_LEVEL
- sys-img-armeabi-v7a-addon-google_apis-google-$EMULATOR_API_LEVEL
licenses:
- 'android-sdk-preview-license-52d11cd2'
- 'android-sdk-license-.+'
- 'google-gdk-license-.+'
before_script:
- echo no | android create avd --force -n test -t "Google Inc.:Google APIs:"$EMULATOR_API_LEVEL --abi $ANDROID_ABI
- emulator -avd test -no-skin -no-audio -no-window &
- android-wait-for-emulator
Link to gradle file:
build.gradle
Github project:
GitHub
The solution is:
add line on top:
sudo: false
Create Emulator Management: Create, Start and Wait
before_script:
- echo no | android create avd --force -n test -t android-21 --abi armeabi-v7a
- emulator -avd test -no-skin -no-audio -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82 &
Now Travis CI works.

Categories