Android CI使用Bitbucket管道和Docker

Rya*_*n R 24 continuous-integration android bitbucket docker bitbucket-pipelines

我正在尝试在Android的Bitbucket管道中设置持续集成(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
Run Code Online (Sandbox Code Playgroud)

由于uber/android-build-environment期望像这样运行,因此需要进行一些更改:

docker run -i -v $PWD:/project -t uber/android-build-environment /bin/bash /project/ci/build.sh
Run Code Online (Sandbox Code Playgroud)

例如,源不会复制到卷/project,而是管道将Bitbucket仓库的内容复制到容器的工作目录:

/opt/atlassian/bitbucketci/agent/build
Run Code Online (Sandbox Code Playgroud)

./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
Run Code Online (Sandbox Code Playgroud)

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
Run Code Online (Sandbox Code Playgroud)

Gen*_*wen 11

这是他们系统中的一个错误,我向他们报告(问题网址,它很长),他们已修复它(修复网址).我已经测试了我的项目并成功构建.现在尝试构建你的项目并祝你好运.

  • 问题中的`bitbucket-pipelines.yml`现在应该没问题了. (2认同)