Jenkins Pipeline DSL:我可以有条件地重试整个阶段吗?

发布于 2025-01-20 16:37:13 字数 629 浏览 5 评论 0原文

有时,我们的Jenkins阶段失败了以下错误:

Emulator did not finish booting within 600 seconds, aborting

这通常是因为VM进入某种类型的低内存状态,并且随后在该VM上启动模拟器的任何尝试都会失败。因此,在这种情况下,我想自动重新执行整个阶段(希望应该自动为新的VM分配)。我该如何实现?

选项{retry(3)}

stage("android-ui-tests") {
  options {
    retry(3) 
  }
  steps {
      // run stage..
  }
}

但是Afaik,这不是条件。像以下类似的API是理想的:

options {
  retry(3) {
    if(exception.contains("Emulator did not finish booting")) {
      // `true` to retry
      return true
    }
    return false
  } 
}

是否存在类似的API?还是可以检查失败并触发重试的帖子条件?

Sometimes our Jenkins stage fails with the following error:

Emulator did not finish booting within 600 seconds, aborting

This usually happens because the VM has entered some type of low memory state and any subsequent attempts to boot the emulator on that VM will failure. So in this scenario, I'd like to automatically re-execute the entire stage as a whole (should hopefully automatically be assigned a new VM). How can I achieve this?

There's options { retry(3) }

stage("android-ui-tests") {
  options {
    retry(3) 
  }
  steps {
      // run stage..
  }
}

But AFAIK, this is not conditional. An API like the following would be ideal:

options {
  retry(3) {
    if(exception.contains("Emulator did not finish booting")) {
      // `true` to retry
      return true
    }
    return false
  } 
}

Does anything like this exist? Or maybe a post condition that could inspect the failure and trigger a retry?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文