CircleCI 在另一个文件夹中出现 gradlew 问题

CircleCI Trouble with gradlew in another folder

我的 CircleCI 有一个问题,我无法开始工作,因为我的 gradlew 文件不在我的存储库的根目录中。由于我的仓库被剥夺了,这里是他的架构的总结:

root
-----> app_folder
------------> some folders
------------> some files
------------> gradlew
------> some files and folders
------> circle.yml

我尝试使用 cd 命令进入 app_folder 文件夹并更改路径变量,但没有任何效果

circle.yml

#
# Build configuration for Circle CI
#

machine:
    environment:
        PATH: "~/$CIRCLE_PROJECT_REPONAME/app_folder:$PATH"
        ANDROID_HOME: /usr/local/android-sdk-linux
        GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"'
        _JAVA_OPTIONS: "-Xms512m -Xmx1024m"
        ADB_INSTALL_TIMEOUT: "10"
        ANDROID_API_LEVEL: 25
        ANDROID_BUILD_TOOLS_VERSION: 25.0.2
    java:
        version: oraclejdk7

dependencies:
    cache_directories:
        - ~/.gradle
        - ~/.android
        - /usr/local/android-sdk-linux/extras

    pre:
        - if [ ! -d "$ANDROID_HOME/tools" ]; then echo y | android update sdk --no-ui --all --filter "tools"; fi
        - if [ ! -d "$ANDROID_HOME/platforms/android-$ANDROID_API_LEVEL" ]; then echo y | android update sdk --no-ui --all --filter "android-$ANDROID_API_LEVEL"; fi
        - if [ ! -d "$ANDROID_HOME/build-tools/$ANDROID_BUILD_TOOLS_VERSION" ]; then echo y | android update sdk --no-ui --all --filter "build-tools-$ANDROID_BUILD_TOOLS_VERSION"; fi
        - if [ ! -d "$ANDROID_HOME/add-ons/addon-google_apis-google-$ANDROID_API_LEVEL" ]; then echo y | android update sdk --no-ui --all --filter "addon-google_apis-google-$ANDROID_API_LEVEL"; fi
        - echo y | android update sdk --no-ui --all --filter "extra-google-m2repository"
        - echo y | android update sdk --no-ui --all --filter "extra-google-google_play_services"
        - echo y | android update sdk --no-ui --all --filter "extra-android-m2repository"

test:
  override:
    # start the emulator
    - emulator -avd circleci-android24 -no-audio -no-window:
        background: true
        parallel: true
    # wait for it to have booted
    - circle-android wait-for-boot
    # unlock the emulator screen
    - sleep 30
    - adb shell input keyevent 82
    # run tests  against the emulator.
    - echo $PATH
    - cd app_folder && .\gradlew connectedAndroidTest -PdisablePreDex
- .\app_folder\gradlew connectedAndroidTest -PdisablePreDex
- .\app_folder\gradlew connectedAndroidTest -PdisablePreDex
- .\gradlew connectedAndroidTest -PdisablePreDex ~/github_name/app_folder
    # copy the build outputs to artifacts
    - cp -r app_folder/app/build/outputs $CIRCLE_ARTIFACTS
    # copy the test results to the test results directory.
    - cp -r app_folder/app/build/outputs/androidTest-results/* $CIRCLE_TEST_REPORTS

你只需要在顶部添加这个:

general:
  build_dir: your_folder

这里有两个选项。最快的是指定一个custom build directory。使用您的示例,这将是:

general:
  build_dir: app_folder

这是因为根据 CircleCI 文档:

CircleCI will run its inference as well as all build commands from that directory.

第二种选择是完全不依赖 CircleCI 的 Inference 命令,而是 运行 一切,比如 Gradle 你自己。您已经覆盖了 test 阶段,因此您还需要覆盖 dependencies 阶段和 运行 gradle dependencies 自己。

例如:

dependencies:
  override:
    - gradle --project-dir app_folder dependencies

-里卡多·N·费利西亚诺
开发人员布道者,CircleCI