为什么在出现错误时我会获得 BUILD SUCCESSFUL?
Why do I get BUILD SUCCESSFUL while I had an error?
我正在试验 Jenkins 和 Ant。我想简单地 运行 我的 Makefile 来完成所有事情,构建和测试。
我发现最好的方法是使用 Ant,因为我的构建过程变得灵活,类似于 travis.yml
。
不幸的是,我使用的编译器只存在于 Windows 上,所以我在 Windows 上安装了 Jenkins。我写了这个build.xml
<?xml version="1.0"?>
<project name="Hello World Project" default="info">
<target name="info">
<echo>Hello World - Welcome to Apache Ant!</echo>
<exec executable="make"/>
</target>
</project>
到目前为止我得到的输出是这个:
C:\Program Files (x86)\Jenkins\workspace\test>exit 0
[test] $ cmd.exe /C "ant.bat info && exit %%ERRORLEVEL%%"
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre1.8.0_131\lib\tools.jar
Buildfile: C:\Program Files (x86)\Jenkins\workspace\test\build.xml
info:
[echo] Hello World - Welcome to Apache Ant!
[exec] rm -f test_*.s
[exec] arm-none-eabi-gcc.exe -O2 -Wall -S -c test.c -o test_gcc.s
[exec] make: arm-none-eabi-gcc.exe: Command not found
[exec] make: *** [Makefile:9: test_gcc.s] Error 127
[exec] Result: 2
BUILD SUCCESSFUL
Total time: 0 seconds
Finished: SUCCESS
为什么我在遇到错误时得到 BUILD SUCCESSFUL
状态?
N.B。我知道我必须配置我的 PATH 以包含工具链。我想首先了解这种不一致。
默认情况下,Ant 的 exec
任务在返回错误代码时不会使构建失败。但是,这可以简单地通过 failonerror
属性打开:
<exec executable="make" failonerror="true" />
我正在试验 Jenkins 和 Ant。我想简单地 运行 我的 Makefile 来完成所有事情,构建和测试。
我发现最好的方法是使用 Ant,因为我的构建过程变得灵活,类似于 travis.yml
。
不幸的是,我使用的编译器只存在于 Windows 上,所以我在 Windows 上安装了 Jenkins。我写了这个build.xml
<?xml version="1.0"?>
<project name="Hello World Project" default="info">
<target name="info">
<echo>Hello World - Welcome to Apache Ant!</echo>
<exec executable="make"/>
</target>
</project>
到目前为止我得到的输出是这个:
C:\Program Files (x86)\Jenkins\workspace\test>exit 0
[test] $ cmd.exe /C "ant.bat info && exit %%ERRORLEVEL%%"
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre1.8.0_131\lib\tools.jar
Buildfile: C:\Program Files (x86)\Jenkins\workspace\test\build.xml
info:
[echo] Hello World - Welcome to Apache Ant!
[exec] rm -f test_*.s
[exec] arm-none-eabi-gcc.exe -O2 -Wall -S -c test.c -o test_gcc.s
[exec] make: arm-none-eabi-gcc.exe: Command not found
[exec] make: *** [Makefile:9: test_gcc.s] Error 127
[exec] Result: 2
BUILD SUCCESSFUL
Total time: 0 seconds
Finished: SUCCESS
为什么我在遇到错误时得到 BUILD SUCCESSFUL
状态?
N.B。我知道我必须配置我的 PATH 以包含工具链。我想首先了解这种不一致。
默认情况下,Ant 的 exec
任务在返回错误代码时不会使构建失败。但是,这可以简单地通过 failonerror
属性打开:
<exec executable="make" failonerror="true" />