简体   繁体   中英

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.

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

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._

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.

You could add one more command to catch this case:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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