如何在 Jenkins 声明性管道中禁用 bitbucket 的构建通知

Zan*_*nev 7 git bitbucket jenkins jenkins-pipeline jenkins-declarative-pipeline

我在多分支管道上使用此代码片段时遇到了问题

if (currentBuild.rawBuild.getCauses().toString().contains('BranchIndexingCause')) {
  print "INFO: Build skipped due to trigger being Branch Indexing"
  currentBuild.result = 'ABORTED' // optional, gives a better hint to the user that it's been skipped, rather than the default which shows it's successful
  return
}

pipeline{
........
Run Code Online (Sandbox Code Playgroud)

虽然代码本身很好地完成了它的工作并中止了构建,但我仍然得到

[Bitbucket] Notifying pull request build result
[Bitbucket] Build result notified
Run Code Online (Sandbox Code Playgroud)

我想跳过 bitbucket 通知,因为每当以前的构建成功时,这段代码都会使其显示为失败,从而造成混乱。

如何在 Bitbucket 中保留显示的最后结果

由于该代码片段位于 Jenkinsfile 中,它是否会在运行之前就中止构建