Incorrect return code for failed folder comparision through batch script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ravindra
    Enthusiast
    • Dec 2018
    • 24

    Incorrect return code for failed folder comparision through batch script

    Hi,

    I created batch file where it compares dll versions after build deployment to make sure all files moved correctly from staging. Now I want to integrate this batch file with Jenkins but unfortunately even folder comparison failed also, it is returning code "0" . Due to this entire automation became not handy as some one has to check manually results after every build deployment. Is there any work around to overcome this?

    Batch file:

    set lfoder=%1
    set rfolder=%2
    set allresult=%3
    set batchfile=%4
    "C:\Program Files\Beyond Compare 4\BCompare.exe" -silent @%batchfile% %lfoder% %rfolder% %allresult%
    echo %ErrorLevel%
  • Aaron
    Team Scooter
    • Oct 2007
    • 16017

    #2
    Hello,

    For the batch file, I recommend using BComp.com to capture the return code. BCompare.exe and Bcomp.exe won't wait in this environment.

    However, which return code are you trying to capture? When running in @script mode, the only return codes expected are related to scripting (successfully run, or the script error conditions). Since @script can perform any series of actions, it does not return if folders are equal; for that you would need to generate and parse the Report file.
    Aaron P Scooter Software

    Comment

    • ravindra
      Enthusiast
      • Dec 2018
      • 24

      #3
      Aaron,

      Thanks for quick reply.What is Bcomp.com? and how to use it in script.

      In text result report, I don't see any codes to parse.Can you please guide me on this?

      Comment

      • Aaron
        Team Scooter
        • Oct 2007
        • 16017

        #4
        BComp.com sits in the same install directory as BCompare.exe, and makes the command line wait while called, which helps with processing error codes during a command line run.

        From the Help article -> Command Line Reference chapter:
        "
        BCompare.exe
        This is the main application. Only one copy will run at a time, regardless of how many windows you have open. If you launch a second copy it will tell the existing copy to start a comparison and exit immediately.

        BComp.exe
        This is a Win32 GUI program. If launched from a version control system, it should work just fine. If launched from a console window, the console (or batch file) will not wait for it.

        BComp.com
        This is a Win32 console program. It has to have a console. If you launch it from one (or a batch file) that console will wait for the comparison to complete before returning. If you launch it from a version control system interactively, it will show a console window while it's waiting.
        "

        However, I think you may be mixing up concepts. Error codes can report back for a variety of reasons. In a simple case, you can use /quickcompare and compare two files and receive status on those files in an error code form. However, there is no parallel for a folder level comparison.

        Scripting can run a variety of complex commands, such as a single script file that could open two folders, copy specific files, generate a file report on a selected subset, then open two other folders and delete a filtered set of files as a series of sequential commands. The Error code for this is either the script finished successfully to completion, or encountered an error. There isn't an error code for the load since script is not limited to a single load command or comparison.

        Script can generate a Folder Compare report or Text Compare Report on a selection of files; either report can be output in a variety of layout types or output types (text or html). This output does not result in an comparison status error code, but the report itself is the data and could be parsed for information, such as the XML dump or Summary types.
        Aaron P Scooter Software

        Comment

        • ravindra
          Enthusiast
          • Dec 2018
          • 24

          #5
          Thank Aaron for the prompt and detailed response. Appreciate your help. Incase if other users who have results in text file, this batch file fails when file comparison fails.. This solved my requirement.

          echo off
          set reulstfile=%1
          echo %reulstfile%
          findstr /m "<> << >>" %reulstfile%
          echo %errorlevel%
          IF "%errorlevel%" EQU "0" (
          GOTO ERROR
          ) ELSE (
          echo "all files matched"
          GOTO EXIT
          )

          :ERROR
          ECHO.
          ECHO ***** Files comparision failed. Go to results file: %reulstfile% to review the files mismatched *****

          :EXIT

          Comment

          Working...