我不知道如何在多分支管道上设置隐藏通知程序插件。配置页没有"生成后操作部分"。
Stash Notifier现在支持管道版本1.11。
根据自述文件中的示例:
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
}
虽然它说设置currentBuild.result是"!重要!",但我的经验是,只有当你的步骤还没有做到这一点时,情况才会如此。例如,如果您有sh "false"
,则不需要将其封装在try/catch中,因为sh
步骤将在非零退出代码上将生成结果设置为失败。只有当您需要自定义成功/失败逻辑时,这才是必要的。
我认为它仍然与管道或多分支管道作业类型不兼容。
我认为Abhijeet Kamble的意思是,你可以使用http客户端或curl自己发送更新。
类似这样的东西:
withCredentials([[$class : 'UsernamePasswordMultiBinding', credentialsId: "$env.componentCredentialsId",
usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
writeFile file: 'build.json', text: "{"state": "SUCCESSFUL", "key": "${env.JOB_NAME}", "name": "${env.BUILD_TAG}", "url": "${env.BUILD_URL}"}"
sh '''curl -u $USERNAME:$PASSWORD -H "Content-Type: application/json" -X POST $URL -d @build.json'''
}
请注意,这是一个非常简单的例子,没有插件那么复杂。
使用Stash Notifier,将其添加为Jenkins构建作业配置中的Post Step。
在Jenkins作业配置中,转到构建后操作部分,单击添加构建后操作并选择Notify Stash Instance输入Stash基本URL,e. g. http://localhost:7990 or http://my.company/stash.
如果有疑问,请转到您当地的Stash服务器并在浏览器中检查URL。例如,URL http://georg@localhost:7991/projects
显示了服务器的基本URL,在本例中为http://localhost:7991
。使用凭据插件选择要存储的凭据。