【问题标题】:How to make pre-build step script in Jenkins to skip the job and make it SUCCESS?如何在 Jenkins 中制作预构建步骤脚本以跳过工作并使其成功?
【发布时间】:2012-05-24 21:45:06
【问题描述】:

我想在 Jenkins 作业中运行预构建步骤 shell/perl,并且在某些条件下,我希望它跳过其余的作业,但仍使其成功。有什么办法吗?

感谢您的宝贵时间。

【问题讨论】:

    标签: hudson jenkins jenkins-plugins


    【解决方案1】:

    我使用通过Groovy plugin 运行的系统 Groovy 脚本构建步骤来完成:

    def thr = Thread.currentThread()
    def thisBuild = thr?.executable
    
    thisBuild.setResult(hudson.model.Result.SUCCESS)
    thisBuild.executor.interrupt(hudson.model.Result.SUCCESS)
    

    警告:一些插件(最突出的是运行条件插件)不能优雅地处理“中断构建”(尽管据我所知它们必须这样做)并且如果构建步骤“属于”它们在该代码之后运行,那么构建将失败.

    【讨论】:

    • 很好,谢谢。但我想知道一件事:我刚刚安装了插件和一个非常简单的 groovy 脚本,但我一直在收到诸如 Caught: java.lang.NoClassDefFoundError: org/apache/commons/jelly/JellyException java.lang 之类的错误.NoClassDefFoundError: org/apache/commons/jelly/JellyException 原因:java.lang.ClassNotFoundException: org.apache.commons.jelly.JellyException 构建步骤“执行 Groovy 脚本”将构建标记为失败 通知上游项目作业完成完成:失败. 我会在 groovy 类路径中包含哪些 jar 以使其正常工作
    • 我不知道 - 我从来没有遇到过这个问题。看起来像一个单独的 SO 问题的候选人。
    • 不,这是我的错。我使用的是“groovy script”,而不是“system groovy script”。
    • 我收到以下错误You attempted to use a method 'hudson' but left out brackets in a place not allowed by the grammar. @ line 18, column 29. thisBuild.setResult(hudson.model.Result.SUCCESS)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-06
    • 1970-01-01
    相关资源
    最近更新 更多