我已经安装了Jenkins来在CI系统中构建应用程序。在构建的配置中,我设置了我想要使用gradle包装器。我已将Wrapper位置设置为:
C:\Users\myuser\myproject\android\MyAppFolder
在要执行的任务列表中,我放了build
。
构建“成功”但实际上它不构建应用程序。
如果我转到命令行并运行
.\gradlew build
它有效。
如果不是运行“构建”而是从Jenkins运行“任务”,这就是我在日志中看到的:
14:00:07 [Android] $ cmd.exe /C "C:\Users\myuser\myproject\android\MyAppFolder\gradlew.bat tasks build && exit %%ERRORLEVEL%%"
14:00:12 :tasks
14:00:12
14:00:12 ------------------------------------------------------------
14:00:12 All tasks runnable from root project
14:00:12 ------------------------------------------------------------
14:00:12
14:00:12 Build Setup tasks
14:00:12 -----------------
14:00:12 init - Initializes a new Gradle build. [incubating]
14:00:12 wrapper - Generates Gradle wrapper files. [incubating]
14:00:12
14:00:12 Help tasks
14:00:12 ----------
14:00:12 buildEnvironment - Displays all buildscript dependencies declared in root project 'Android'.
14:00:12 components - Displays the components produced by root project 'Android'. [incubating]
14:00:12 dependencies - Displays all dependencies declared in root project 'Android'.
14:00:12 dependencyInsight - Displays the insight into a specific dependency in root project 'Android'.
14:00:12 dependentComponents - Displays the dependent components of components in root project 'Android'. [incubating]
14:00:12 help - Displays a help message.
14:00:12 model - Displays the configuration model of root project 'Android'. [incubating]
14:00:12 projects - Displays the sub-projects of root project 'Android'.
14:00:12 properties - Displays the properties of root project 'Android'.
14:00:12 tasks - Displays the tasks runnable from root project 'Android'.
14:00:12
14:00:12 To see all tasks and more detail, run gradlew tasks --all
14:00:12
14:00:12 To see more detail about a task, run gradlew help --task <task>
所以看起来构建应用程序的任务不存在。看起来我实际上指的是其他一些“根项目”。
修改 看起来问题就在这里:
cmd.exe /C "C:\Users\myuser\myproject\android\MyAppFolder\gradlew.bat tasks build && exit %%ERRORLEVEL%%"
如果我从命令行执行相同的操作,我会遇到同样的问题。如果我更改目录然后运行gradlew build
一切正常。
看起来如果我从不同的文件夹运行它,使用的gradle.build不是正确的