none
problem with evaluating env. variables with EnableDelayedExpansion

    Question

  • Hi,

    I have below cmd script, which causes me a problem:

    @echo off
    setlocal EnableDelayedExpansion
    set JENKINS_ERROR=0 
    set ERRORLEVEL=0
    echo ERRORLEVEL_start !ERRORLEVEL!
    echo JENKINS_ERROR_start !JENKINS_ERROR!
    
    IF NOT !ERRORLEVEL! == 0 ( 
    echo Setting JENKINS_ERROR to 1 
    set JENKINS_ERROR=1
    )
    
    echo JENKINS_ERROR_middle !JENKINS_ERROR!
    IF NOT !JENKINS_ERROR! == 0 (
    echo Setting ERRORLEVEL to -1 
    set ERRORLEVEL=-1
    )
    echo ERRORLEVEL_end !ERRORLEVEL!
    echo JENKINS_ERROR_end !JENKINS_ERROR!

    No matter what, ERRORLEVEL is always set to -1, but I don't quite understand why? JENKINS_ERROR variable is set to 0 so the script should not go to line set ERRORLEVEL=-1. Any idea what's wrong with my script?

    Have a nice day,
    Pavel K.

    • Moved by Jamles Hez Thursday, June 18, 2015 8:19 AM
    Monday, June 15, 2015 3:39 PM

Answers

All replies

  • It seems that there is no Application Compatibility issue in your post. So your post in off-topic here.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, June 18, 2015 8:18 AM
  • Maybe something here helps.

    https://wiki.jenkins-ci.org/display/JENKINS/Build+Failure+Analyzer

     

     

     


    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

    Thursday, June 18, 2015 12:27 PM
    Moderator