简体   繁体   English

配置Jenkins在一定时间后向Slack发出警报?

[英]Configure Jenkins to alert Slack after certain amount of time?

I have a jenkins pipeline that goes through dev, stage and prod. 我有一条贯穿开发,阶段和生产的詹金斯管道。 At each stage the user has manually trigger the next stage of the pipeline. 在每个阶段,用户都可以手动触发管道的下一个阶段。 We frequently forget to do this. 我们经常忘记这样做。 Is there any a way to configure the jenkins slack plugin to alert in a channel after something has been in a stage for a certain period of time? 有什么方法可以配置jenkins松弛插件,使其在某个阶段进入特定时间段后在频道中发出警报? Or something similar to that? 还是类似的东西? Thanks! 谢谢!

I was able to make something similar work by using the timeout option from Jenkins DSL to expire the blocked task. 通过使用Jenkins DSL的timeout选项使被阻止的任务过期,我能够进行类似的工作。

This does use an exception for controlling the flow of the implementation. 这确实使用异常来控制实现流程。 Using exceptions in this way is not "best practice" in my experience, but it does achieve the result I wanted. 以这种方式使用异常并不是我的经验中的“最佳实践”,但确实可以达到我想要的结果。

def result;

while (!result?.trim()) {
  try {
    timeout (activity: true, time: 2) {
      result = input "Enter some value"
    }
  } catch (ex) {
    //Timeout Exception
    echo "No value entered within time period.  Sending Reminders."
    //Other work goes here, or calls appropriate notify function.
  }
}

echo result

Best of luck 祝你好运

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM