Android CI 使用 Bitbucket 管道和 Docker
Android CI using Bitbucket Pipelines and Docker
我正尝试在 Bitbucket Pipelines 中为 Android 设置持续集成 (CI)。
我使用 Android Studio 2.1.1 创建了一个样本空白 activity。
对于管道,我正在使用 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
,而是管道将 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
您能否在容器内将您的项目从 /opt/atlassian/bitbucketci/agent/build
符号链接到 /project
? ln -s /opt/atlassian/bitbucketci/agent/build /project
是您需要的命令。
或者将文件复制到新路径?
我没有 android 开发经验,所以 YMMV :)
这是他们系统中的一个错误,我报告了它(issue url, it's quite long) to them and they have fixed it (fix url)。我已经对我的项目进行了测试,它成功地build.Try现在可以构建你的项目,祝你好运。
看来 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
我正尝试在 Bitbucket Pipelines 中为 Android 设置持续集成 (CI)。
我使用 Android Studio 2.1.1 创建了一个样本空白 activity。
对于管道,我正在使用 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
,而是管道将 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
您能否在容器内将您的项目从 /opt/atlassian/bitbucketci/agent/build
符号链接到 /project
? ln -s /opt/atlassian/bitbucketci/agent/build /project
是您需要的命令。
或者将文件复制到新路径?
我没有 android 开发经验,所以 YMMV :)
这是他们系统中的一个错误,我报告了它(issue url, it's quite long) to them and they have fixed it (fix url)。我已经对我的项目进行了测试,它成功地build.Try现在可以构建你的项目,祝你好运。
看来 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