24

我正在尝试在Android的Bitbucket Pipelines中设置持续集成 (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 存储库的内容复制到容器的工作目录:

/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
4

3 回答 3

11

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

于 2016-07-22T06:37:26.220 回答
1

好像uber/android-build-environment不再支持了。

我最终javiersantos/android-ci改用它从头开始完美运行。

只需将以下内容添加到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
于 2018-08-29T22:09:21.967 回答
0

您可以在容器内将您的项目从符号链接/opt/atlassian/bitbucketci/agent/build到从符号链接吗?是您需要的命令。/projectln -s /opt/atlassian/bitbucketci/agent/build /project

或者将文件复制到新路径?

我没有android开发经验,所以YMMV :)

于 2016-06-03T05:07:48.103 回答