Gitlab Ci gradlew:不存在且--remove未通过

时间:2019-06-17 07:10:54

标签: android gitlab gitlab-ci

我点击this链接以在示例项目中实现一个简单的Gitlab ci。
这是我的Gitlab ci配置

image: openjdk:8-jdk

variables:
  ANDROID_COMPILE_SDK: "28"
  ANDROID_BUILD_TOOLS: "28.0.2"
  ANDROID_SDK_TOOLS:   "4333796"

before_script:
  - apt-get --quiet update --yes
  - apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1
  - wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/sdk-tools-linux-${ANDROID_SDK_TOOLS}.zip
  - unzip -d android-sdk-linux android-sdk.zip
  - echo y | android-sdk-linux/tools/bin/sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" >/dev/null
  - echo y | android-sdk-linux/tools/bin/sdkmanager "platform-tools" >/dev/null
  - echo y | android-sdk-linux/tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}" >/dev/null
  - export ANDROID_HOME=$PWD/android-sdk-linux
  - export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/
  - chmod +x ./gradlew
  # temporarily disable checking for EPIPE error and use yes to accept all licenses
  - set +o pipefail
  - yes | android-sdk-linux/tools/bin/sdkmanager --licenses
  - set -o pipefail

stages:
  - build
  - test

lintDebug:
  stage: build
  script:
    - ./gradlew -Pci --console=plain :app:lintDebug -PbuildDir=lint

assembleDebug:
  stage: build
  script:
    - ./gradlew assembleDebug
  artifacts:
    paths:
    - app/build/outputs/

debugTests:
  stage: test
  script:
    - ./gradlew -Pci --console=plain :app:testDebug

,但找不到gradlew,并且始终显示此错误

$ chmod +x ./gradlew
chmod: cannot access './gradlew': No such file or directory
ERROR: Job failed: exit code 1

2 个答案:

答案 0 :(得分:1)

如果要运行./gradlew,必须在Git中跟踪此文件或在before_script中生成/安装该文件。似乎这没有发生。

很可能您没有通过将gradlew文件添加到Git或在.gitignore文件中忽略它来跟踪gradlew文件。 确保在VCS中跟踪laravel-excel文件。

答案 1 :(得分:0)

在您的variables中,添加以下内容: ANDROID_GRADLE_VERSION: "gradle-5.1.1"

然后在您的before_script中将其添加到chmod +x ./gradlew之前:

- wget --quiet --output-document=gradle.zip https://services.gradle.org/distributions/${ANDROID_GRADLE_VERSION}-bin.zip
- unzip -q gradle.zip