简体   繁体   English

从 jenkins shell 脚本执行时 Diff 命令失败

[英]Diff command failing when executed from jenkins shell script

The diff command I execute is simple, but failing when given from excecute shell script of jenkins.我执行的 diff 命令很简单,但是当从 jenkins 的 execute shell 脚本给出时失败。

echo 'diff Delta_changes_current.txt Delta_changes_previous.txt >> PR.DELTA.FILES'
chmod 777 delta.sh
. ./delta.sh
diff Delta_changes_current.txt Delta_changes_previous.txt

Build step 'Execute shell' marked build as failure构建步骤“执行 shell”将构建标记为失败

there is not even an error to find out what is the issue with this.甚至没有错误可以找出问题所在。

When I am running the same from server directly the command is giving result.当我直接从服务器运行相同的命令时,命令给出了结果。

can someone plz help me find what needs to be done有人可以帮我找到需要做的事情吗

.. ..

The above snippet is from logs.上面的片段来自日志。 Let me paste the logs by running the command only ..让我只通过运行命令来粘贴日志..


+ diff Delta_changes_current.txt Delta_changes_previous.txt
1,4c1
< ################################# Delta_Changes_currect file for Junit##########
< 
< /OptionlessVDDSController.java
< /OptionlessVDDSControllerTest_.java
\ No newline at end of file
---
> /OracleBroker.java
Build step 'Execute shell' marked build as failure

Its printing output and failing immediately它的打印输出并立即失败

According to the diff man-page:根据差异手册页:

_ Exit status is 0 if inputs are the same, 1 if different, 2 if trouble._ _ 输入相同时退出状态为 0,不同时为 1,故障时为 2。_

If the files are different, diff sets exit status 1. Jenkins treats an execution step as failed, if it returns with an exit status different from 0.如果文件不同, diff将退出状态设置为 1。Jenkins 将执行步骤视为失败,如果它返回的退出状态不同于 0。

You could add one more command to catch this case:您可以再添加一个命令来捕获这种情况:

(( $? < 2 )) && true # Convert status 1 to 0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM