我可以通知Bitbucket Jenkins上的构建被中止吗?

huangapple go评论50阅读模式
英文:

Can I notify Bitbucket that build was aborted on Jenkins?

问题

I would like Bitbucket to be notified when my build on Jenkins is aborted. Currently, such build is marked as failed. Is it possible to distinguish aborted from failed on Bitbucket?

我希望当我在Jenkins上的构建被中止时,Bitbucket能够收到通知。目前,这样的构建被标记为失败。在Bitbucket上是否可能区分中止和失败?

I was looking at Bitbucket docs, but I cannot find anything useful.

我查看了Bitbucket的文档,但我找不到有用的信息。

I have tried Bitbucket Build Status Notifier Plugin, but it appears they consider aborted failed -> https://github.com/jenkinsci/bitbucket-build-status-notifier-plugin/blob/1.4.0/src/main/java/org/jenkinsci/plugins/bitbucket/BitbucketBuildStatusHelper.java#L212-L213

我尝试了Bitbucket Build Status Notifier插件,但似乎他们认为中止等同于失败 -> https://github.com/jenkinsci/bitbucket-build-status-notifier-plugin/blob/1.4.0/src/main/java/org/jenkinsci/plugins/bitbucket/BitbucketBuildStatusHelper.java#L212-L213

英文:

I would like Bitbucket to be notified when my build on Jenkins is aborted. Currently, such build is marked as failed. Is it possible to distinguish aborted from failed on Bitbucket?

I was looking at Bitbucket docs, but I cannot find anything useful.
I have tried Bitbucket Build Status Notifier Plugin, but it appears they consider aborted failed -> https://github.com/jenkinsci/bitbucket-build-status-notifier-plugin/blob/1.4.0/src/main/java/org/jenkinsci/plugins/bitbucket/BitbucketBuildStatusHelper.java#L212-L213

答案1

得分: 1

post部分,你可以有一个aborted部分。

post {
  aborted {
    // 通知 BitBucket
  }
}

如果你想要 BitBucket 构建状态变成其他状态,你可以在aborted块中使用 BitBucket API(文档)来操作它。

这个文档中的示例展示了如何强制提交具有“成功”状态:

curl https://api.bitbucket.org/2.0/repositories/my-workspace/my-repo/commit/e10dae226959c2194f2b07b077c07762d93821cf/statuses/build/ -X POST -u jdoe -H 'Content-Type: application/json' -d '{
    "key": "MY-BUILD",
    "state": "SUCCESSFUL",
    "description": "42 tests passed",
    "url": "https://www.example.org/my-build-result"
  }'
英文:

In the post section, you could have a section aborted.

post {
  aborted {
    // Notify BitBucket
  }
}

If you want the BitBucket build status to be something else, you can manipulate it within the aborted block using the BitBucket API (doc).

This block from the docs show how you can force the commit to have a "successful" status:

curl https://api.bitbucket.org/2.0/repositories/my-workspace/my-repo/commit/e10dae226959c2194f2b07b077c07762d93821cf/statuses/build/           -X POST -u jdoe -H 'Content-Type: application/json'           -d '{
    "key": "MY-BUILD",
    "state": "SUCCESSFUL",
    "description": "42 tests passed",
    "url": "https://www.example.org/my-build-result"
  }'

huangapple
  • 本文由 发表于 2023年7月3日 21:50:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/76605392.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定