Jenkins - 运行 Gradle 构建 - 失败

Jenkins - Running Gradle build - failed

提问人:Utkarsh 提问时间:11/16/2023 更新时间:11/16/2023 访问量:58

问:

我目前正在致力于自动化 APK 构建过程,为项目设置 Jenkins 管道。我的 Jenkins 位于安装了 npm、Ionic、OpenJDK、Android SDK 和 Gradle 的 Docker 容器上。
我们的团队在项目中使用了电容器。我正在将这 2 个命令用于管道中的“构建 APK”阶段

 sh "npx cap build android --keystorepath app/release.keystore --keystorealias \${KEY_STORE_ALIAS} --keystorepass \${KEY_STORE_PASS} --keystorealiaspass \${KEY_STORE_ALIAS_PASS} --androidreleasetype APK"
 sh "/opt/android-sdk/build-tools/30.0.3/apksigner sign --ks android/app/release.keystore --ks-key-alias \${KEY_STORE_ALIAS} --ks-pass \"pass:\${KEY_STORE_PASS}\" --key-pass \"pass:\${KEY_STORE_ALIAS_PASS}\" --v1-signing-enabled true --v2-signing-enabled true --out android/app/build/outputs/apk/release/app-release-signed-v1-v2.apk android/app/build/outputs/apk/release/app-release-unsigned.apk"

但是,我在 Jenkins 控制台中遇到了一个错误:

> Task :capacitor-cordova-android-plugins:compileReleaseJavaWithJavac FAILED
        
        > Task :capacitor-google-maps:compileReleaseKotlin
        w: /var/jenkins_home/workspace/apk-pipeline/node_modules/@capacitor/google-maps/android/src/main/java/com/capacitorjs/plugins/googlemaps/CapacitorGoogleMap.kt: (589, 48): Variable 'stream' initializer is redundant
        
        FAILURE: Build failed with an exception.
        
        * What went wrong:
        Execution failed for task ':capacitor-cordova-android-plugins:compileReleaseJavaWithJavac'.
        > error: invalid source release: 17
        
        * 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
        
        BUILD FAILED in 44s

然后我在build.gradle文件中将gradle版本更改为8.0

    dependencies {
        classpath 'com.android.tools.build:gradle:7.2.1'

现在我在 Jenkins 控制台中遇到了这个错误:

[Pipeline] sh
+ npx cap build android --keystorepath app/release.keystore --keystorealias \${KEY_STORE_ALIAS} --keystorepass \${KEY_STORE_PASS} --keystorealiaspass \${KEY_STORE_ALIAS_PASS} --androidreleasetype APK
✖ Running Gradle build - failed!
[error] Starting a Gradle Daemon (subsequent builds will be faster)
        
        FAILURE: Build failed with an exception.
        
        * What went wrong:
        A problem occurred configuring root project 'android'.
        > Could not resolve all files for configuration ':classpath'.
        > Could not find com.android.tools.build:gradle:8.0.
        Searched in the following locations:
        - https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/8.0/gradle-8.0.pom
        - https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/8.0/gradle-8.0.pom
        Required by:
        project :
        
        * 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
        
        BUILD FAILED in 9s

请让我知道如何解决这个问题,或者是否有其他命令可用于在没有 Android Studio 的情况下构建已签名的 APK。

Gradle Jenkins 离子框架 电容器 CICD

评论


答: 暂无答案