3

Can anyone hint me - what is wrong with this step? I need to check, that application is deployed and website is up^

stage('Check Availability') {
  agent any
  steps {             
    timeout(time: 15, unit: 'SECONDS') {
      waitUntil {
        try {         
          sh "curl -s --head  --request GET  localhost:8081/actuator/health | grep '200'"
              return true
          } catch (Exception e) {
            return false
        }
      }
    }
  }
}

But I cannot understand what is wrong with groovy syntax. Right now I receive error.

WorkflowScript: 50: Expected a step @ line 50, column 15.
try {
^

http://prntscr.com/jdycje

Vasyl Stepulo
  • 1,493
  • 1
  • 23
  • 43

1 Answers1

0

Following works for me:

Pipline {
    agent any
    timeout(time: 15, unit: 'SECONDS') {
        stage('Check Availability') {
          steps {             
              waitUntil {
                  try {         
                      sh "curl -s --head  --request GET  localhost:8081/actuator/health | grep '200'"
                      return true
                  } catch (Exception e) {
                        return false
                  }
              }
           }
       }
    }
}
Sagar
  • 23,903
  • 4
  • 62
  • 62
  • Ok, with this, I receive 2 another errors - WorkflowScript: 45: Unknown stage section "timeout". Starting with version 0.5, steps in a stage must be in a steps block. @ line 45, column 5. stage('Check Availability') { ^ WorkflowScript: 45: No "steps" or "parallel" to execute within stage "Check Availability" @ line 45, column 5. stage('Check Availability') { ^ http://prntscr.com/je080i – Vasyl Stepulo May 05 '18 at 09:14