在Jenkins 2.0 multibranch管道上使用stash notifier插件

Tom*_*eyn 4 jenkins bitbucket-server jenkins-2

我不知道如何在multibranch管道上设置stash通知程序插件.配置页面没有"构建后操作"部分.

mro*_*ney 8

Stash Notifier现在支持版本1.11的管道.

README中示例:

node {
    step([$class: 'StashNotifier'])         // Notifies the Stash Instance of an INPROGRESS build

    try {
        // Do stuff
        currentBuild.result = 'SUCCESS'     // Set result of currentBuild !Important!
    } catch(err) {
        currentBuild.result = 'FAILED'      // Set result of currentBuild !Important!
    }

    step([$class: 'StashNotifier'])         // Notifies the Stash Instance of the build result
}
Run Code Online (Sandbox Code Playgroud)

虽然它说设置currentBuild.result是"!重要!",但我的经验是,只有你的步骤还没有这样做才会出现这种情况.例如,如果有sh "false",则不需要将其包装在try/catch中,因为该sh步骤将在非零退出代码上将构建结果设置为失败.只有在需要自定义成功/失败逻辑时才需要这样做.


Abh*_*ble 0

通过将 Stash Notifier 添加为 Jenkins 构建作业配置中的后期步骤来使用它。

在 Jenkins 作业配置中,转到“构建后操作”部分,单击“添加构建后操作”并选择“通知存储实例”,输入存储基 URL,e. g. http://localhost:7990 or http://my.company/stash.

如果有疑问,请访问本地 Stash 服务器并检查浏览器中的 URL。例如,URLhttp://georg@localhost:7991/projects显示了本例中的服务器基本 URL http://localhost:7991。使用凭据插件选择用于存储的凭据。