使用 Bitbucket Pipelines 和 Docker 的 Android CI

Android CI using Bitbucket Pipelines and Docker(使用 Bitbucket Pipelines 和 Docker 的 Android CI)

本文介绍了使用 Bitbucket Pipelines 和 Docker 的 Android CI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Android 的 Bitbucket Pipelines 中设置持续集成 (CI).

I am trying to set up Continuous Integration (CI) in Bitbucket Pipelines for Android.

我使用 Android Studio 2.1.1 创建了一个示例空白活动.

I have created a sample blank activity using Android Studio 2.1.1.

对于 Pipelines,我使用的是 uber/android-build-environment Docker 容器很好地创造了环境.这是我的 bitbucket-pipelines.yml

With Pipelines I'm using the uber/android-build-environment Docker container which creates the environment nicely. Here is my 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

需要进行一些更改,因为 uber/android-build-environment 预计会像这样运行:

Some changes are needed since uber/android-build-environment is expecting to be run like so:

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

例如,源不是复制到卷 /project 而是 Pipelines 将 Bitbucket repo 的内容复制到容器的工作目录:

For example, the source is not copied to the volume /project but instead Pipelines copies the contents of the Bitbucket repo to the working directory of the container at:

/opt/atlassian/bitbucketci/agent/build

./gradlew assembleDebug 运行时,我收到以下错误:

And when ./gradlew assembleDebug is run I get the following 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

在工作目录中运行 ls -al 给出:

Running ls -al in the working directory gives:

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

推荐答案

这是他们系统中的一个错误,我报告它(issue url,这很长)给他们,他们已经修复了它(fix url).我已经对我的项目进行了测试,它成功构建了.现在尝试构建你的项目,祝你好运.

It's a bug in their system , I report it(issue url, it's quite long) to them and they have fixed it (fix url).I have tested on my project and it successfully build.Try to build your project now and good luck.

这篇关于使用 Bitbucket Pipelines 和 Docker 的 Android CI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:使用 Bitbucket Pipelines 和 Docker 的 Android CI

基础教程推荐