Android CI usando Bitbucket Pipelines y Docker


Estoy tratando de configurar la Integración continua (CI) en Bitbucket Pipelines para Android.

He creado una actividad en blanco de muestra usando Android Studio 2.1.1.

Con Pipelines estoy usando el contenedor Docker uber/android-build-environment que crea el entorno muy bien. Aquí está mi bitbucket-pipelines.yml

image: uber/android-build-environment:latest

pipelines:
  default:
    - step:
        script:
          - echo y | android update sdk --filter "extra-android-m2repository" --no-ui -a # Grab the Android Support Repo which isn't included in the container
          - ./gradlew assembleDebug

Se necesitan algunos cambios ya que uber/android-build-environment se espera que se ejecute así:

docker run -i -v $PWD:/project -t uber/android-build-environment /bin/bash /project/ci/build.sh

Por ejemplo, el origen no se copia al volumen /project, sino que Pipelines copia el contenido del repositorio de Bitbucket al directorio de trabajo del contenedor en:

/opt/atlassian/bitbucketci/agent/build

Y cuando se ejecuta ./gradlew assembleDebug obtengo el siguiente error:

...

FAILURE: Build failed with an exception.

* What went wrong:
Could not create service of type TaskArtifactStateCacheAccess using TaskExecutionServices.createCacheAccess().
> Failed to create parent directory '/opt/atlassian/bitbucketci/agent/build/.gradle' when creating directory '/opt/atlassian/bitbucketci/agent/build/.gradle/2.10/taskArtifacts'

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 56.449 secs

Ejecutando ls -al en el directorio de trabajo se obtiene:

ls -al
total 52
drwxr-xr-x 5 root root 4096 May 31 22:33 .
drwxr-xr-x 3 root root 4096 May 31 22:43 ..
drwxr-xr-x 3 root root 4096 May 31 22:33 app
-rw-r--r-- 1 root root  462 May 31 22:33 bitbucket-pipelines.yml
-rw-r--r-- 1 root root  498 May 31 22:33 build.gradle
drwxr-xr-x 8 root root 4096 May 31 22:33 .git
-rw-r--r-- 1 root root  387 May 31 22:33 .gitignore
drwxr-xr-x 3 root root 4096 May 31 22:33 gradle
-rw-r--r-- 1 root root  855 May 31 22:33 gradle.properties
-rwxr-xr-x 1 root root 4971 May 31 22:33 gradlew
-rw-r--r-- 1 root root 2314 May 31 22:33 gradlew.bat
-rw-r--r-- 1 root root   15 May 31 22:33 settings.gradle
Author: Matthew Schinckel, 2016-06-01

3 answers

Es un bug en su sistema , lo informo(issue url, es bastante largo) a ellos y lo han solucionado (fix url).He probado en mi proyecto y construir con éxito.Intenta construir tu proyecto ahora y buena suerte.

 11
Author: Geng Jiawen,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-07-22 06:37:26

¿Podrías enlazar tu proyecto desde /opt/atlassian/bitbucketci/agent/build a /project desde el contenedor? ln -s /opt/atlassian/bitbucketci/agent/build /project es el comando que necesitarás.

O, alternativamente, copiar los archivos a la nueva ruta?

No tengo experiencia con el desarrollo de Android, por lo que YMMV :)

 0
Author: Preflightsiren,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-06-03 05:07:48

Parece que uber/android-build-environment ya no está soportado.

Terminé usando javiersantos/android-ci en su lugar, que funciona perfectamente desde cero.

Simplemente agregue el siguiente contenido a bitbucket-pipeline.yml:

image: javiersantos/android-ci:27.0.3

pipelines:
  default:
    - step:
        script:
          - export GRADLE_USER_HOME=`pwd`/.gradle
          - chmod +x ./gradlew
          - ./gradlew assembleDebug
 0
Author: Oleksandr Shpota,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-08-30 08:47:30