如何用jenkins构建android项目?

时间:2015-09-15 22:33:37

标签: android jenkins gradle

我一直在尝试设置jenkins来构建基于gradle的android项目。

这是我到目前为止所做的事情:

  1. Bitnami与Jenkins Stack一起推出了EC2实例。
  2. 成功测试了打印"正常运行时间"每一分钟。
  3. 已安装的Android SDK工具。
  4. 但是现在当我配置一个用它来构建android项目的作业时,我得到一个奇怪的异常,我认为这与我的ubuntu机器上的一些权限有关。

    这是堆栈跟踪:

        First time build. Skipping changelog.
    [workspace] $ /bin/sh -xe /opt/bitnami/apache-tomcat/temp/hudson1533897385497543877.sh
    + whoami
    tomcat
    + echo Starting Build
    Starting Build
    [Gradle] - Launching build.
    [workspace] $ gradle clean
    Could not load Logmanager "org.apache.juli.ClassLoaderLogManager"
    java.lang.ClassNotFoundException: org.apache.juli.ClassLoaderLogManager
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.util.logging.LogManager$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.util.logging.LogManager.<clinit>(Unknown Source)
        at org.gradle.logging.internal.JavaUtilLoggingConfigurer.configure(JavaUtilLoggingConfigurer.java:36)
        at org.gradle.logging.internal.DefaultLoggingConfigurer.configure(DefaultLoggingConfigurer.java:34)
        at org.gradle.logging.internal.LoggingSystemAdapter.setLevel(LoggingSystemAdapter.java:55)
        at org.gradle.logging.internal.LoggingSystemAdapter.on(LoggingSystemAdapter.java:42)
        at org.gradle.logging.internal.DefaultLoggingManager$StartableLoggingSystem.start(DefaultLoggingManager.java:191)
        at org.gradle.logging.internal.DefaultLoggingManager.start(DefaultLoggingManager.java:60)
        at org.gradle.logging.internal.DefaultLoggingManager.start(DefaultLoggingManager.java:31)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:201)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
        at org.gradle.launcher.Main.doAction(Main.java:33)
        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
        at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Failed to create parent directory '/opt/bitnami/.gradle/caches/2.6/scripts' when creating directory '/opt/bitnami/.gradle/caches/2.6/scripts/settings_i62l96mhihwg5udfskdyy53h/cp_settings'
    
    * 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: 2.27 secs
    Build step 'Invoke Gradle script' changed build result to FAILURE
    Build step 'Invoke Gradle script' marked build as failure
    Finished: FAILURE
    

    准备提供任何人要求的任何其他信息。请建议我该怎么做。

2 个答案:

答案 0 :(得分:0)

我和詹金斯一起工作了很长时间,这可能是出于很多原因。首先,我要检查jenkins的环境变量。添加一个构建setp echo $ PATH因为这看起来像java一样找不到一些库。将此PATH变量与本地变量进行比较。此外,安装任何新东西后,请务必执行http:// {your_jenkins_url} / restart。

答案 1 :(得分:0)

可能与:https://community.bitnami.com/t/gradle-user-home-opt-bitnami-gradle/40717

有关

默认情况下,bitnami jenkins / gradle设置似乎将GRADLE_USER_HOME指向jenkins / gradle无法写入的目录,因此各种下载/缓存以神秘的方式失败。