contentdb icon indicating copy to clipboard operation
contentdb copied to clipboard

(GitLab?) Webhooks don't work with non-default branches.

Open Warr1024 opened this issue 5 years ago • 2 comments

Summary

For NodeCore, I have the following setup:

  • The nodecore_alpha package tracks the dev branch of gitlab.com/sztest/nodecore, which can receive frequent new commits for new development. I want this package to always track as close as possible to the current state of development.
  • The nodecore package tracks the master branch of gitlab.com/sztest/nodecore, which receives occasional fast-forward merges from the dev branch as things stabilize. I want this package to track approved stable versions of the code, which I manage by moving the branch head.

I want to use webhooks to manage each of these. This would involve setting up 2 webhooks in a single gitlab repo pointing to different CDB packages. Gitlab does not appear to provide any way to filter or otherwise configure webhooks; any push of any ref(s) would cause both webhooks to fire each time.

I want pushing to the dev branch to trigger a release of nodecore_alpha only, pushing to the master branch to trigger a release of nodecore only, and pushing unrelated (e.g. topic) branches not to trigger any releases. I also want the releases to use the correct source branch, but there's nowhere to associate a branch with a package (the association appears to only exist at the time a release is created).

Steps to reproduce
  1. Setup a repository in GitLab.
  2. Setup a package in CDB meant to track a branch other than master in CDB.
  3. Push commits to that branch.
Expected behavior:

CDB creates a release for the package from the dev branch.

Observed behavior:

CDB creates a release for the package from the master branch.

Other scenarios to test:

(Have one package tracking master and one tracking dev)

  • Pushes to master should create a release on the master-tracking package from the master branch.
  • Pushes to master should NOT create a release on the dev-tracking branch.
  • Pushes to the dev branch should NOT create a release on the master-tracking branch.

Warr1024 avatar Dec 31 '20 15:12 Warr1024

I think there are three issues here:

  • A bug: ContentDB creates a release from the wrong reference specified by a GitLab webhook. CDB reads json["after"] to find the commit hash after the push. (this issue)
  • A bug: ContentDB treats Git VCS as a unique value, so multiple packages having the same repo will confuse it. (New: #264)
  • A feature: The ability to ignore all webhooks not on the specified branch (New: #265)

rubenwardy avatar Jan 01 '21 15:01 rubenwardy

I want to use webhooks to manage each of these. This would involve setting up 2 webhooks in a single gitlab repo pointing to different CDB packages.

FYI: you should be able to one webhook with an API Token not bound to a package once #264 is fixed

rubenwardy avatar Jan 01 '21 15:01 rubenwardy