Execution failed for task ':app:connectedDebugAndroidTest'. Gitlab CI - java

i am using gitlab ci to test my apk and to do that i needed a virtual device so i can test my instrumented test to take screenshots with fastlane commande but when i try to run ./gradlew connectedAndroidTest in gitlab using this pipeline
image: mingc/android-build-box:latest
stages:
- ui-test
- build
- test
variables:
LC_ALL: "en_US.UTF-8"
LANG: "en_US.UTF-8"
before_script:
- chmod +x ./gradlew
- gem install fastlane
- export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/
build:
stage: build
script:
- fastlane build
artifacts:
paths:
- "app/build/outputs/"
tags:
- docker
ui-test:
stage: ui-test
script:
- export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/
# Add missing folder to the PATH, to use sdkmanager
- export ADB_INSTALL_TIMEOUT=30
- export USE_SDK_WRAPPER=True
# Insall and run emulator
- sdkmanager "platform-tools" "platforms;android-27" "emulator"
- sdkmanager "system-images;android-27;google_apis;arm64-v8a"
- adb devices
# Create an ARM-based emulator AVD with 250 MB SD car
- echo "no" | avdmanager create avd -n Android_7.0_API_24 -k "system-images;android-27;google_apis;arm64-v8a" -c 250M --force
# Check the image is properly created and available to run
- emulator -list-avds
- emulator -avd Android_7.0_API_24 -no-audio -no-window -gpu off &
- adb wait-for-device devices
- echo "Emulator is ready"
- adb devices
- export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/
- ./gradlew connectedAndroidTest
- fastlane screenshots
tags:
- docker
test:
stage: test
script:
- fastlane test
tags:
- docker
I got this error even if this test got no error while i run it in android studio
[PropertyFetcher]: ShellCommandUnresponsiveException getting properties for device emulator-5554
java.lang.Throwable: ShellCommandUnresponsiveException getting properties for device emulator-5554
at com.android.ddmlib.PropertyFetcher.handleException(PropertyFetcher.java:248)
at com.android.ddmlib.PropertyFetcher.access$500(PropertyFetcher.java:30)
at com.android.ddmlib.PropertyFetcher$1.run(PropertyFetcher.java:211)
Caused by: com.android.ddmlib.ShellCommandUnresponsiveException
at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:689)
at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:468)
at com.android.ddmlib.internal.DeviceImpl.executeShellCommand(DeviceImpl.java:705)
at com.android.ddmlib.PropertyFetcher$1.run(PropertyFetcher.java:207)
[PropertyFetcher]: ShellCommandUnresponsiveException getting properties for device emulator-5554
java.lang.Throwable: ShellCommandUnresponsiveException getting properties for device emulator-5554
at com.android.ddmlib.PropertyFetcher.handleException(PropertyFetcher.java:248)
at com.android.ddmlib.PropertyFetcher.access$500(PropertyFetcher.java:30)
at com.android.ddmlib.PropertyFetcher$1.run(PropertyFetcher.java:211)
Caused by: com.android.ddmlib.ShellCommandUnresponsiveException
at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:689)
at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:468)
at com.android.ddmlib.internal.DeviceImpl.executeShellCommand(DeviceImpl.java:705)
at com.android.ddmlib.PropertyFetcher$1.run(PropertyFetcher.java:207)
> Task :app:connectedDebugAndroidTest
Skipping device 'Android_7.0_API_24(AVD)' for 'app:': Unknown API Level
> : No compatible devices connected.[TestRunner] FAILED
Found 1 connected device(s), 0 of which were compatible.
> Task :app:connectedDebugAndroidTest FAILED
FAILURE: Build failed with an exception.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.2/userguide/command_line_interface.html#sec:command_line_warnings
61 actionable tasks: 61 executed
* What went wrong:
Execution failed for task ':app:connectedDebugAndroidTest'.
> There were failing tests. See the report at: file:///builds/chaimae.bousaid/myapplication/app/build/reports/androidTests/connected/index.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 6m 24s
Cleaning up project directory and file based variables
00:32
ERROR: Job failed: exit code 1
does any one have any idea to solve it i have been solving this error for a mounth

Related

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.

How can I build this gradle project (KotlinParcelize) from the command line (Ubuntu 18.04, fail: Wrong plugin option format)?

I found this article: https://android.jlelse.eu/yet-another-awesome-kotlin-feature-parcelize-5439718ba220 - and I wanted to look at the code there, https://github.com/burakeregar/KotlinParcelize.
I am using Ubuntu 18.04, and I thought of running ./gradlew in terminal.
My Android SDK dir is in, say, /path/to/adt-bundle-linux-x86-20140321/sdk ...
So, I did:
$ cd /tmp
$ git clone https://github.com/burakeregar/KotlinParcelize.git KotlinParcelize_git
Cloning into 'KotlinParcelize_git'...
remote: Enumerating objects: 75, done.
remote: Total 75 (delta 0), reused 0 (delta 0), pack-reused 75
Unpacking objects: 100% (75/75), done.
$ cd KotlinParcelize_git/
$ ./gradlew assembleDebug
Downloading https://services.gradle.org/distributions/gradle-4.1-all.zip
.....................................................................
Unzipping //home/user/.gradle/wrapper/dists/gradle-4.1-all/bzyivzo6n839fup2jbap0tjew/gradle-4.1-all.zip to //home/user/.gradle/wrapper/dists/gradle-4.1-all/bzyivzo6n839fup2jbap0tjew
Set executable permissions for: //home/user/.gradle/wrapper/dists/gradle-4.1-all/bzyivzo6n839fup2jbap0tjew/gradle-4.1/bin/gradle
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine java version from '11.0.8'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
Eh, so a Java problem; my default is java 11, but I have java 8 too, so try that:
$ apt-show-versions -r openjdk | grep uptodate
openjdk-11-jre:amd64/bionic-security 11.0.8+10-0ubuntu1~18.04.1 uptodate
openjdk-11-jre-headless:amd64/bionic-security 11.0.8+10-0ubuntu1~18.04.1 uptodate
openjdk-8-jdk:amd64/bionic-security 8u265-b01-0ubuntu2~18.04 uptodate
openjdk-8-jdk-headless:amd64/bionic-security 8u265-b01-0ubuntu2~18.04 uptodate
openjdk-8-jre:amd64/bionic-security 8u265-b01-0ubuntu2~18.04 uptodate
openjdk-8-jre-headless:amd64/bionic-security 8u265-b01-0ubuntu2~18.04 uptodate
$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 auto mode
1 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 manual mode
2 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 manual mode
Press <enter> to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java to provide /usr/bin/java (java) in manual mode
Ok, try again:
$ ./gradlew assembleDebug
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 0s
Right, so I do:
$ echo sdk.dir=/path/to/adt-bundle-linux-x86-20140321/sdk > local.properties
Ok, try again:
$ ./gradlew assembleDebug
> Configure project :app
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
Observed package id 'build-tools;19.0.3' in inconsistent location '/path/to/adt-bundle-linux-x86-20140321/sdk/build-tools/android-4.4.2' (Expected '/path/to/adt-bundle-linux-x86-20140321/sdk/build-tools/19.0.3')
Checking the license for package Android SDK Build-Tools 26.0.2 in /path/to/adt-bundle-linux-x86-20140321/sdk/licenses
Warning: License for package Android SDK Build-Tools 26.0.2 not accepted.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> You have not accepted the license agreements of the following SDK components:
[Android SDK Build-Tools 26.0.2].
Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
Ok, so I run /path/to/adt-bundle-linux-x86-20140321/sdk/tools/android, install Build-Tools 26.0.2 (apparently the minimum version for the gradle version in the repo, and those build tools I did not have before), try again:
$ git add -f local.properties # so it does not get deleted by git clean
$ git clean -dxf
$ ./gradlew --stop
Stopping Daemon(s)
1 Daemon stopped
$ ./gradlew assembleDebug
Starting a Gradle Daemon, 5 stopped Daemons could not be reused, use --status for details
> Configure project :app
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
Observed package id 'build-tools;19.0.3' in inconsistent location '/path/to/adt-bundle-linux-x86-20140321/sdk/build-tools/android-4.4.2' (Expected '/path/to/adt-bundle-linux-x86-20140321/sdk/build-tools/19.0.3')
Observed package id 'build-tools;19.0.3' in inconsistent location '/path/to/adt-bundle-linux-x86-20140321/sdk/build-tools/android-4.4.2' (Expected '/path/to/adt-bundle-linux-x86-20140321/sdk/build-tools/19.0.3')
e: Wrong plugin option format: null, should be plugin:<pluginId>:<optionName>=<value>
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Compilation error. See log for more details
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 10s
12 actionable tasks: 12 executed
If you run ./gradlew assembleDebug --debug, you get a massive log of some 6400+ lines, which I pasted here: KotlinParcelize_gradlew_debug.log, the only relevant part seems to be:
...
12:05:09.468 [DEBUG] [sun.rmi.transport.tcp] RMI TCP Connection(2)-127.0.0.1: accepted socket from [127.0.0.1:26356]
12:05:09.469 [DEBUG] [sun.rmi.transport.tcp] RMI TCP Connection(2)-127.0.0.1: (port 1757) op = 80
12:05:09.469 [DEBUG] [sun.rmi.loader] RMI TCP Connection(2)-127.0.0.1: name = "[Ljava.rmi.server.ObjID;", codebase = "", defaultLoader = sun.misc.Launcher$ExtClassLoader#3d7dbe2d
12:05:09.469 [DEBUG] [sun.rmi.loader] RMI TCP Connection(2)-127.0.0.1: name = "java.rmi.server.ObjID", codebase = "", defaultLoader = sun.misc.Launcher$ExtClassLoader#3d7dbe2d
12:05:09.470 [DEBUG] [sun.rmi.loader] RMI TCP Connection(2)-127.0.0.1: name = "java.rmi.server.UID", codebase = "", defaultLoader = sun.misc.Launcher$ExtClassLoader#3d7dbe2d
12:05:09.470 [DEBUG] [sun.rmi.loader] RMI TCP Connection(2)-127.0.0.1: name = "java.rmi.dgc.Lease", codebase = "", defaultLoader = sun.misc.Launcher$ExtClassLoader#3d7dbe2d
12:05:09.472 [DEBUG] [sun.rmi.loader] RMI TCP Connection(2)-127.0.0.1: name = "java.rmi.dgc.VMID", codebase = "", defaultLoader = sun.misc.Launcher$ExtClassLoader#3d7dbe2d
12:05:09.473 [DEBUG] [sun.rmi.loader] RMI TCP Connection(2)-127.0.0.1: name = "[B", codebase = "", defaultLoader = sun.misc.Launcher$ExtClassLoader#3d7dbe2d
12:05:09.488 [DEBUG] [sun.rmi.transport.tcp] RMI TCP Connection(2)-127.0.0.1: (port 1757) op = 82
12:05:09.488 [DEBUG] [sun.rmi.transport.tcp] RMI TCP Connection(2)-127.0.0.1: (port 1757) op = 80
12:05:09.521 [DEBUG] [sun.rmi.transport.tcp] RMI TCP Connection(2)-127.0.0.1: (port 1757) op = 82
12:05:09.526 [DEBUG] [sun.rmi.transport.tcp] RMI TCP Connection(2)-127.0.0.1: (port 1757) op = 80
12:05:09.526 [ERROR] [org.gradle.api.Task] e: Wrong plugin option format: null, should be plugin:<pluginId>:<optionName>=<value>
12:05:09.532 [DEBUG] [sun.rmi.transport.tcp] RMI TCP Connection(2)-127.0.0.1: (port 1757) op = 80
12:05:09.533 [DEBUG] [sun.rmi.loader] RMI TCP Connection(2)-127.0.0.1: name = "org.jetbrains.kotlin.daemon.report.CompileIterationResult", codebase = ""
12:05:09.533 [DEBUG] [sun.rmi.loader] RMI TCP Connection(2)-127.0.0.1: name = "java.util.LinkedHashSet", codebase = ""
12:05:09.533 [DEBUG] [sun.rmi.loader] RMI TCP Connection(2)-127.0.0.1: name = "java.util.HashSet", codebase = ""
12:05:09.533 [DEBUG] [sun.rmi.loader] RMI TCP Connection(2)-127.0.0.1: name = "java.io.File", codebase = ""
12:05:09.534 [DEBUG] [org.gradle.api.Project] [KOTLIN] compile iteration: app/src/main/java/com/burakeregar/kotlinparcelize/MainActivity.kt, app/src/main/java/com/burakeregar/kotlinparcelize/PersonModel.kt, app/src/main/java/com/burakeregar/kotlinparcelize/SecondActivity.kt
...
... but I still cannot understand - what plugin is in "Wrong plugin option format"?
Well, I'm stuck here .... How can I get this example to compile?
EDIT: few things I found:
e: Wrong plugin option format: null, should be plugin:<pluginId>:<optionName>=<value> is apparently a message from kotlinc (I guess, the kotlin compiler), as noted in KT-41303:
CLI: "wrong plugin option format: null, should be plugin::=" with compiler plugins
So, it would have been nice to see when and how ./gradlew calls kotlinc - however, not even --debug does not output such a command line, because "That's not possible. Simply, because most of the Gradle tasks do not invoke CLI commands." ( How can I view the CLI command executed by a Gradle task in Android Studio? )
I tried importing this in Android Studio 4.0.1, and at a certain time, I got the message Unsupported Modules Detected: Unfortunately you can't have non-Gradle Java modules and Android-Gradle modules in one project ; then I deleted .idea folder, reimported again - did not get that message anymore, but still same plugin null error
Bit more digging in the debug log, it can be determined that the compileDebugKotlin step is the one failing, which can be triggered with ./gradlew :app:compileDebugKotlin --info - but still the same error.
Well, finally opened the project with Android Studio 4.0.1, and:
Updated gradle in project to 6.1.1 (from the original 4.1)
Updated to ext.kotlin_version = '1.3.72' from 1.2.0
Used kotlin-stdlib-jdk7 instead of kotlin-stdlib-jre7 (because I got a deprecation message somewhere)
... and now I do not get the "Wrong plugin option format" anymore - but now I get "Class 'PersonModel' is not abstract and does not implement abstract member public abstract ..." - which I'll ask a new question about.

CircleCI + Gradle + Heroku deployment

I'm trying to provide a continuous deployment with Gradle and Heroku but for some reason, the deployment step is not running.
CircleCI Pipeline result
I've already updated the circle ci with the Heroku key.
version: 2
jobs:
build:
docker:
- image: circleci/openjdk:8-jdk
working_directory: ~/repo
environment:
JVM_OPTS: -Xmx3200m
TERM: dumb
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "build.gradle" }}
- v1-dependencies-
- run: gradle dependencies
- save_cache:
paths:
- ~/.m2
key: v1-dependencies-{{ checksum "build.gradle" }}
# run tests!
- run: gradle test
deployment:
staging:
branch: master
heroku:
appname: my-heroku-app
Could you guys help me, please? Is the deployment step in the right place?
You are using deployment configuration for CircleCI 1.0 but you are using CircleCI 2.0.
From the documentation for CircleCI 2.0:
The built-in Heroku integration through the CircleCI UI is not
implemented for CircleCI 2.0. However, it is possible to deploy to
Heroku manually.
To deploy on heroku with CircleCI 2.0, you need :
add environment variables HEROKU_LOGIN, HEROKU_API_KEY, HEROKU_APP_NAME to your CircleCI project settings https://circleci.com/gh/<account>/<project>/edit#env-vars
create a private ssh key without passphrase and add it to your CircleCI project settings https://circleci.com/gh/https://circleci.com/gh/<account>/<project>/edit#ssh for hostname git.heroku.com
add steps in the .circleci/config.yml file with the fingerprint of your ssh key
- run:
name: Setup Heroku
command: |
ssh-keyscan -H heroku.com >> ~/.ssh/known_hosts
cat > ~/.netrc << EOF
machine api.heroku.com
login $HEROKU_LOGIN
password $HEROKU_API_KEY
EOF
cat >> ~/.ssh/config << EOF
VerifyHostKeyDNS yes
StrictHostKeyChecking no
EOF
- add_ssh_keys:
fingerprints:
- "<SSH KEY fingerprint>"
- deploy:
name: "Deploy to Heroku"
command: git push --force git#heroku.com:$HEROKU_APP_NAME.git HEAD:refs/heads/master

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.

jasmine_node failed while running mean-seed

Having trouble running a project generated by yeoman generator called mean-seed. I've been tinkering with it for a few days now and tried a couple things. Where I am having trouble is running the "jasmine_node" task:
Running "jasmine_node" task
>> Error: Unable to access jarfile node_modules/protractor/selenium/selenium-server-standalone-2.39.0.jar
Warning: Done, with errors. Use --force to continue.
Aborted due to warnings.
So I first tried identifying missing npm packages to install
744 npm install && bower update && bower install
755 npm install protractor
760 npm install npm install selenium-standalone
761 npm install -g protractor
765 npm install protractor-tester
767 npm install protractor-selenium-server-vagrant
768 npm install selenium-standalone#2.39.0-2.8.0-2
none of these actually created the file selenium-server-standalone-2.39.0.jar in the node_modules directory. I ran a find to check, however several other jars were install.
$ find . -name "*.jar" -print
./node_modules/grunt-jasmine-node-coverage-validation/node_modules/jasmine-node/node_modules/jasmine-reporters/ext/jline.jar
./node_modules/grunt-jasmine-node-coverage-validation/node_modules/jasmine-node/node_modules/jasmine-reporters/ext/js.jar
./node_modules/selenium-standalone/.selenium/2.39.0/server.jar
I found the selenium server download so I tried downloading and copying it over to the referenced directory which I had to create
https://code.google.com/p/selenium/downloads/detail?name=selenium-server-standalone-2.39.0.jar
I run grunt again. It goes through tasks then runs the jasmine_node task
Running "jasmine_node" task
TEST configFile: /Users/jgs/Projects/mean/app/test/../configs/config.test.json
configFile: ./app/configs/config.test.json
info - socket.io started
waiting for server to be running..
[success] connected to db at localhost:27017/test_temp
>> Feb 01, 2014 3:03:54 PM org.openqa.grid.selenium.GridLauncher main
>> INFO: Launching a standalone server
>> Setting system property webdriver.chrome.driver to node_modules/protractor/selenium/chromedriver
------------------
[ERROR]
Run `node run.js config=test`
Server not connected. Ensure you have a node server running with the `config=test` command line option so this server connects to the TEST database - the same one used here for the tests. Do NOT connect to the live database for doing tests!
------------------
[success] connected to db at localhost:27017/test_temp
all tests - 2526 ms
should test everything - 2525 ms
Failures:
1) all tests should test everything
Message:
Expected 'ERROR - check the logs above to fix the problem then try again' to be false.
Stacktrace:
Error: Expected 'ERROR - check the logs above to fix the problem then try again' to be false.
at /Users/jgs/Projects/mean/app/test/all.spec.js:6:2935
at _rejected (/Users/jgs/Projects/mean/node_modules/q/q.js:808:24)
at /Users/jgs/Projects/mean/node_modules/q/q.js:834:30
at Promise.when (/Users/jgs/Projects/mean/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/Users/jgs/Projects/mean/node_modules/q/q.js:752:41)
at /Users/jgs/Projects/mean/node_modules/q/q.js:574:44
at flush (/Users/jgs/Projects/mean/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
Finished in 2.53 seconds
1 test, 1 assertion, 1 failure, 0 skipped
Warning: Task "jasmine_node" failed. Use --force to continue.
Aborted due to warnings.
$
Any idea why jasmine task is still failing?
Run ./node_modules/protractor/bin/webdriver-manager update, see here for more info:
https://github.com/jackrabbitsgroup/generator-mean-seed/issues/5
I hadn't yet updated the documentation everywhere yet for the Protractor upgrade, sorry about that!
Here is my solution.
First you need to download both the selenium-server-standalone
https://code.google.com/p/selenium/downloads/detail?name=selenium-server-standalone-2.39.0.jar
and the chromedriver
http://chromedriver.storage.googleapis.com/index.html
copy them to
node_modules/protractor/selenium/
you will want another terminal tab or window to start the node server by runing
node run.js
then you can run the default grunt task
grunt
You will then see the output of the selenium tests in the console and chrome should open and perform the tests automatically.

Categories