我正在尝试在Android的Bitbucket管道中设置持续集成(CI)。
我使用Android Studio 2.1.1创建了一个示例空白活动。
通过管道,我使用的是uber / android-build- environment Docker容器,可以很好地创建环境。这是我的bitbucket-pipelines.yml
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存储库的内容复制到容器的工作目录,位于:
/project
/opt/atlassian/bitbucketci/agent/build
当./gradlew assembleDebug运行时,出现以下错误:
./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
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
这是他们系统中的错误,我向他们报告了这个问题(问题url,它很长),他们已经修复了它(fix url)。我已经在我的项目上进行了测试,并成功构建了。现在尝试构建您的项目,祝您好运。