【问题标题】:Cannot execute a shell script from gradle file无法从 gradle 文件执行 shell 脚本
【发布时间】:2015-05-11 21:19:26
【问题描述】:

我使用 TeamCity 作为我的 CI 服务器。我有一个 android 项目的 build.gradle 文件,其中包含

android{project.afterEvaluate{
task packDex(type:Exec)  {
    ....
    commandLine './script.sh'
    .....
}
}

在构建我的项目时,我收到了 org.gradle.process.internal.ExecException 错误。我该如何解决这个问题。它在 Android Studio 中构建,但不在 TeamCity 中。我正在使用 gradle wrapper 来构建我的项目。请帮帮我。

编辑:

我的简单疑问是命令commandLine './script.sh' 是否正确从build.gradle 文件启动shell 脚本。我使用Mac 作为我的服务器并使用gradle 1.0.0

【问题讨论】:

  • 关于上述异常的任何进一步细节?你提供的信息完全没用。
  • @Opal A problem occurred starting process 'command './script.sh '' 错误只有这么多。连我都没有太多信息
  • 尝试使用-d-s 开关运行构建以获取更多信息。基本上配置没问题。 script.sh 是否设置了 +x 模式?
  • ./script.sh 可执行吗?您是否在 commandLine xxxxx 之前的任务中设置了可执行的“bash”或可执行的“sh”?另一件事,您使用的是 Gradle 1.0.0?我建议,至少使用大于 1.6 的最新版本。
  • 还有一点需要注意的是:stackoverflow.com/questions/15776431/…,你也可以试试:commandLine "bash", "./script.sh" 因为commandLine是一个列表,每个参数都成为一个单独的元素那个清单。随意使用 bash 或 sh。

标签: android bash android-studio gradle teamcity


【解决方案1】:

我自己解决了这个问题。只需使用以下代码。

android{project.afterEvaluate{
task packDex(type:Exec)  {
....
commandLine 'sh', './myScript.sh'
.....
}
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-29
    • 1970-01-01
    • 2017-06-24
    • 1970-01-01
    相关资源
    最近更新 更多