【问题标题】:Can a Jenkins job set the description build upon starting the buildJenkins 作业可以在开始构建时设置描述构建吗
【发布时间】:2015-02-05 01:13:10
【问题描述】:

我熟悉 Description Setter 插件 (https://wiki.jenkins-ci.org/display/JENKINS/Description+Setter+Plugin),但它只是作为构建后操作。我有一些很长的测试版本,我想在一开始就设置构建描述 - 作为预构建或作为构建步骤。

【问题讨论】:

    标签: plugins jenkins


    【解决方案1】:

    您还可以添加一个常规构建步骤(应该是第一步),它将使用构建参数,如下所示:

    /* Get System name, version, user name */
    def system  = build.getEnvironment(listener).get('system')
    def version = build.getEnvironment(listener).get('system_version')
    def user    = build.getEnvironment(listener).get('USERNAME')
    
    /* Build description with params and send description to currentbuild */
    def description = "$system / $version / $user"
    currentBuild.setDescription(description)
    

    【讨论】:

      【解决方案2】:

      由于我的构建是从 Python 脚本提交的,因此我在脚本中添加了一个杂项:
      1.等到它开始执行并在作业中找到它的构建ID(我可以通过使用的构建参数唯一地标识我的构建)
      2. 有了作业名称和内部版本号,使用 Jenkins CLI(jar 文件)设置描述。

      诚然,Slav 提出的方案更优雅,但我还没有来得及测试它……一旦测试了,我会在这里报告。

      【讨论】:

        【解决方案3】:

        使用pre-scm-build stepConditional Build Step 插件。在全局配置中,找到“Conditional Build step”部分,然后选择“any builder”(或类似的东西)。这将允许插件使用任何构建或构建后步骤。

        然后在作业配置中,在 Build Environment 下,使用“Run buildstep before SCM runs”,然后选择 Conditional Build Step。将条件保留为“always”,然后选择“Description Setter”。

        FWIW,在我使用最新插件的环境中,我可以从 pre-SCM 步骤执行“描述设置器”,而无需条件构建步骤。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2017-07-19
          • 2016-07-29
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多