可以开发自定义的Bitbucket远程服务器钩子,以拒绝推送。

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

Can you develop custom bitbucket remote server hook that can reject pushes?

问题

I found out about bitbucket's custom plugins and allegedly you can implement custom hooks as java apps that you can connect with bitbucket's git repo. One example: https://blog.developer.atlassian.com/beer-o-clock-stash-plugin-tutorial/. In this example plugin is used as a part of the custom "Stash" server that is run on the localhost. My question is: could that same custom plugin be used on an existing bitbucket remote repo somehow, and can you point me in a right direction on how to achieve that?

英文:

During my research on how to implement a solution for filtering commits on bitbucket's git repo, i.e. rejecting pushes that introduce invalid changes, I found out about bitbucket's custom plugins and allegedly you can implement custom hooks as java apps that you can connect with bitbucket's git repo. One example: https://blog.developer.atlassian.com/beer-o-clock-stash-plugin-tutorial/.

In this example plugin is used as a part of the custom "Stash" server that is run on the localhost. My question is: could that same custom plugin be used on an existing bitbucket remote repo somehow, and can you point me in a right direction on how to achieve that?

答案1

得分: 1

以下是翻译好的部分:

这里的答案取决于您是使用托管版本的Bitbucket(也称为Bitbucket Cloud;位于bitbucket.org)还是使用本地版本的Bitbucket(也称为Bitbucket Server或Bitbucket Datacenter,以前称为Stash;位于其他主机名)。

如果您托管Bitbucket实例,那么您可以使用文档https://confluence.atlassian.com/bitbucketserver/using-repository-hooks-776639836.html添加自己的预接收和/或更新挂钩。请注意,预接收挂钩在每次推送时运行一次,而更新挂钩在每次分支推送时运行一次。

如果您使用Atlassian托管的Bitbucket,则出于安全性和可靠性原因,您无法添加自己的预接收或更新挂钩。(github.com和gitlab.com类似情况。)

无论哪种情况,您都可以使用CI/CD系统来测试是否满足特定条件,或者您可以要求您的团队安装类似pre-commit的工具,并在那里执行一些检查,或者两者都可以。

英文:

The answer here depends on whether you're using the hosted version of Bitbucket (also known as Bitbucket Cloud; found at bitbucket.org) or an on-premise version of Bitbucket (known either as Bitbucket Server or Bitbucket Datacenter, and formerly known as Stash; found at some other hostname).

If you're hosting the Bitbucket instance(s), then you can add your own pre-receive and/or update hooks using the documentation at https://confluence.atlassian.com/bitbucketserver/using-repository-hooks-776639836.html. Note that a pre-receive hook runs once per push, and an update hook runs once per branch per push.

If you're using the Bitbucket that Atlassian hosts, then you cannot add your own pre-receive or update hooks, for security and reliability reasons. (Similar story for github.com and gitlab.com.)

In either case, instead of a pre-receive hook, you could use a CI/CD system to test that your specific conditions are met, or you could have your team install a tool like pre-commit and implement some checks there, or you could do both.

huangapple
  • 本文由 发表于 2023年5月17日 16:45:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76270159.html
匿名

发表评论

匿名网友

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

确定