Details
-
Task
-
Resolution: Unresolved
-
Neutral
-
None
-
None
-
None
-
None
-
-
Empty show more show less
-
Empty show more show less
Description
A follow-up ticket to BUILD-1037.
The initial implementation of the git repo mirroring task uses a simple cron job to trigger the relevant command in the magnolia-mgmt app.
However, it would be preferable to trigger the command via webhooks. For instance, Bitbucket offers the ability to trigger a web hook upon certain events (e.g. a push to a given repo).
Some technical issues that need addressing:
- how to pass the necessary parameters (source repo URL and target repo URL) to the lambda function on the receiving end?
Currently we parse the request body in order to retrieve such parameters. - Does Bitbucket allow something similar?
- Could the payload sent by Bitbucket when triggering the webhook be used to that end?
- Do we need a new, ad-hoc endpoint instead?
- Is Bitbucket capable of sending the API Auth token as header parameter as required by the current endpoint?
Ideally the solution should comply with BUILD-1048 so we can reuse the same endpoint. But, if Bitbucket is not able to send the request as required by the convention stated in BUILD-1048, me might need to define a new enpoint for this specific case (or change the convention to address the different cases, if possible).
Discovery
According to Bitbucket server webhook documentation, the relevant points for this task are:
- It's not possible to modify the payload (request body)
- It's possible to add some parameters to the webhook request URL (project.key, repo.slug, etc.)
- It's possible to define webhooks at project level, inherited by the project repositories.
- There are limitations for request authentication.
Therefore, looks like a new magnolia-mgmt API endpoint is needed to receive webhook requests (mainly because authentication restrictions).
The're already two enpoints.
- v1/trigger - Used by renovate and authenticated using x-amazon-apigateway-api header param
- v2/trigger - Used by the magnolia-mgmt-ui using custom lambda authorizer to allow OPTIONS request and with CORS enabled
We might as well implement a third one accepting webhook authenticated requests, but reusing the same magnolia-mgmt-controller.js parsing the request in an standard way as required by BUILD-1048.
Relevant resources:
Checklists
Attachments
Issue Links
- is depended upon by
-
BUILD-1048 Standarize request parsing for magnolia-mgmt's trigger API endpoint
-
- Open
-
- split from
-
BUILD-1037 Turn update_git_mirrors into a magnolia-mgmt task
-
- Closed
-