【发布时间】:2016-09-30 03:58:38
【问题描述】:
我正在尝试在 Bitbucket Pipelines 中为 Android 设置持续集成 (CI)。
我使用 Android Studio 2.1.1 创建了一个示例空白活动。
对于 Pipelines,我正在使用 uber/android-build-environment Docker 容器,它可以很好地创建环境。这是我的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 预计会像这样运行:
docker run -i -v $PWD:/project -t uber/android-build-environment /bin/bash /project/ci/build.sh
例如,源不会复制到卷 /project,而是 Pipelines 将 Bitbucket repo 的内容复制到容器的工作目录:
/opt/atlassian/bitbucketci/agent/build
当./gradlew assembleDebug 运行时,我收到以下错误:
...
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 给出:
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
【问题讨论】:
-
除了使用
uber/android-build-environment:latestDocker 镜像来构建和使用 Bitbucket Pipelines 的基于 Android Gradle 的项目之外,我没有找到其他选择。还有其他方法吗?你的问题解决了吗? -
不幸的是还没有。这似乎是管道而不是构建容器的问题。
-
@RyanR 我是 CI 集成新手,在 android 开发设置方面遇到了问题,所以如果可能的话,你能帮我解决一下使用 Bitbucket 管道设置 CI 的问题
-
@RyanR 加入这个房间来讨论更多chat.stackexchange.com/rooms/46117/ci-intergeation-with-docker
-
@LOG_TAG 当您将更改推送到您的 Bitbucket 项目(存在 bitbucket-pipelines.yml 文件)时,您的 bitbucket-pipelines.yml 中指定的 Docker 映像(在这个问题中,他们使用的是 uber/ android-build-environment Docker)将被下载并在 Bitbucket Pipelines 上运行(在他们的构建服务器上,而不是您的本地机器上)。这个答案可能有助于更清楚:stackoverflow.com/a/40055055/196486
标签: android docker continuous-integration bitbucket bitbucket-pipelines