代码之家  ›  专栏  ›  技术社区  ›  Vasiliy Stepulo

Jenkins管道检查网站可用性问题

  •  3
  • Vasiliy Stepulo  · 技术社区  · 6 年前

    有人能告诉我这个步骤有什么问题吗?我需要检查,该应用程序已部署,网站已启动^

    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
            }
          }
        }
      }
    }
    

    但我无法理解groovy语法的错误。现在我收到错误。

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

    http://prntscr.com/jdycje

    1 回复  |  直到 6 年前
        1
  •  0
  •   Sagar    6 年前

    以下是我的作品:

    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
                      }
                  }
               }
           }
        }
    }