0

i am using while loop inside jenkins stage, below is the code. Issue is with elif [ $siteStatus = "SUCCEEDED" ] statement. once this statement is true i want this step to be completed and go to next step. which is not happening, it again going into loop.

while(currtime < futtime){
                        date = new Date()
                        currtime = date.getTime()

                        sleep(5);
                        sh """
                        export siteStatus= SUCCEEDED
                        
                        if [ \$siteStatus = "IN_PROGRESS" ]
                        then
                         continue
                        elif [ \$siteStatus = "SUCCEEDED" ]
                        then
                         exit 0 
                        else
                         exit 1
                        fi
abhi
  • 41
  • 1
  • 7
  • What happens if you were to go to the Jenkins machine, open a terminal, try running a similar if check with an `exit 0`? It could be an shell level problem that has nothing to do with Jenkins and a test like this could verify that. – M B Apr 19 '22 at 07:48
  • here if exit 1 is working i believe exit 0 should also work, i tired with break command but still no help – abhi Apr 19 '22 at 07:56
  • Yes, which is why I'm suspecting this is something to do with shell being weird as opposed to Jenkins. – M B Apr 19 '22 at 08:11
  • Maybe [`return 0`](https://stackoverflow.com/questions/4419952/difference-between-return-and-exit-in-bash-functions)? – Ian W Apr 19 '22 at 10:05
  • The `export` command doesn't do what you think it does. Remove the space after `=`. – Gordon Davisson Apr 19 '22 at 17:28

0 Answers0