有没有办法在詹金斯声明管道中获得重试号码

发布于 2025-02-08 03:09:17 字数 377 浏览 1 评论 0原文

我正在尝试在Jenkins声明管道中使用重试逻辑,当进行重试时,我需要添加其他逻辑。为此,我需要重试号码,以便可以使用变量添加其他逻辑。作为临时解决方案,我正在尝试按照以下编码来编码,以下面的变量不会增加。请帮忙。

steps{
    script{
        def counter=0
        retry(3){
            //my original logic
            if (counter.toInteger()>0){
                //my additional logic
            }
            counter = counter + 1
        }
    }
}

I am trying to use retry logic in jenkins declarative pipeline, when the retry is happening i need to add additional logic. For that I need retry number so that I can use variable to add additional logic. As a temporary solution i am trying to code as below for which counter variable is not getting incremented. Please help.

steps{
    script{
        def counter=0
        retry(3){
            //my original logic
            if (counter.toInteger()>0){
                //my additional logic
            }
            counter = counter + 1
        }
    }
}

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

幸福不弃 2025-02-15 03:09:17

我得到了解决方案..希望它对某人有帮助。

count= (binding.hasVariable('count)) ? count + 1 : 1

I got the solution.. Hope it helps someone.

count= (binding.hasVariable('count)) ? count + 1 : 1
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文