英文:
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"
}'
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论