此构建中使用了Gitlab CI / CD Show不推荐使用的Gradle功能,使其与Gradle 5.0不兼容

时间:2019-03-28 05:19:08

标签: android android-gradle gitlab gitlab-ci

今天我想在Gitlab上为我的Android项目使用CI / CD。然后,我将 .gitlab-ci.yml 与这样的标准配置一起使用:

image: openjdk:8-jdk #Defining the Docker Image

variables:
  ANDROID_COMPILE_SDK: "28" #set compile SDK version
  ANDROID_BUILD_TOOLS: "28.0.2" #set build tool version
  ANDROID_SDK_TOOLS:   "4333796" #set SDK tool build number you can find yous here https://developer.android.com/studio/releases/sdk-tools

before_script:
#Installing Packages
- apt-get --quiet update --yes
- apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1

#Installing the Android SDK
- 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

#Setting up the environment variable
- export ANDROID_HOME=$PWD/android-sdk-linux
- export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/
- chmod +x ./gradlew #set executable permission

# temporarily disable checking for EPIPE error and use yes to accept all licenses
- set +o pipefail
- yes | android-sdk-linux/tools/bin/sdkmanager --licenses # accept SDK licences
- set -o pipefail
# - build_release_android
stages:
- build_release_android

build_release_android:
  stage: build_release_android
  script:
  - mkdir /PlayJson #make temp directory named PlayJson in root of project
  - "echo $PLAY_STORE_JSON > /PlayJson/play-store-key.json" # copy git variable value to play-store-key.json file
  - ./gradlew publishApkRelease # command to publish app on play store
  only:
  - hotfix/translation #set trigger for CICD if push or merge in master branch
  artifacts:
    paths:
    - ./app/build/outputs/ # set artifact path which store your APK file

然后我将原点推送到我的分支和运行CI / CD的Gitlab,显示如下错误:

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
See https://docs.gradle.org/4.6/userguide/command_line_interface.html#sec:command_line_warnings

在我的Android项目上,使用gradle 3.2.1和类似以下的配置:

buildscript {
    repositories {
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
        maven { url "https://jitpack.io" }
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.2.0'
        classpath 'com.github.triplet.gradle:play-publisher:1.2.0'
        //noinspection GradleDynamicVersion
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
        maven { url "https://jitpack.io" }
        google()
    }
}

task wrapper(type: Wrapper) {
    gradleVersion = '4.4'
    distributionUrl = distributionUrl.replace("bin", "all")
}

我的问题是我们可以在Gitlab上更改配置吗?如果不能,如何解决这种错误?

如果您已经在gitlab上尝试过CI / CD,并且还有其他一些好配置可供我使用,则可以与我共享它们,这也非常有帮助。谢谢

1 个答案:

答案 0 :(得分:0)

问题是 local.properties 必须在 .gitIgnore 中忽略,因此将其放入gitIgnore,然后推送到您的分支。

之后,您必须使用以下命令重置git cache:

git rm -r --cached .

然后再次推送,我保证您的CI / CD可以成功运行。