nautobot / nautobot-app-version-control

Version Control App that uses and requires a Dolt Database
Other
30 stars 6 forks source link

Webhooks are not firing unless the 'main' branch is active #142

Open tim-fiola opened 2 years ago

tim-fiola commented 2 years ago

In the main branch, there are webhooks configured to fire upon a PR create/update event: image

When I create a new PR from the main branch (to merge a non-main branch into main), the webhooks fire: image

dolt_1      | 2021-11-16T23:31:27Z INFO [conn 129] ConnectionClosed {}
nautobot_1  | [16/Nov/2021 23:31:29] "GET /health/ HTTP/1.1" 201 0
nautobot_1  | [16/Nov/2021 23:31:34] "GET /health/ HTTP/1.1" 201 0
dolt_1      | 2021-11-16T23:31:39Z INFO [conn 131] NewConnection {}
nautobot_1  | [16/Nov/2021 23:31:39] "GET /health/ HTTP/1.1" 201 0
dolt_1      | 2021-11-16T23:31:39Z INFO [conn 132] NewConnection {}
worker_1    | [2021-11-16 23:31:39,895: INFO/MainProcess] Task nautobot.extras.tasks.process_webhook[bd4b3106-3a32-4f04-8f4e-a7f1b4427508] received
worker_1    | [2021-11-16 23:31:39,925: INFO/MainProcess] Task nautobot.extras.tasks.process_webhook[3b3b1430-8fb2-4f3f-8287-efdb36d21665] received
dolt_1      | 2021-11-16T23:31:39Z INFO [conn 134] NewConnection {}
dolt_1      | 2021-11-16T23:31:39Z INFO [conn 133] NewConnection {}
worker_1    | [2021-11-16 23:31:39,980: INFO/ForkPoolWorker-6] Sending POST request to https://jenkins.demo.networktocode.com/generic-webhook-trigger/invoke?token=1175cee50e0de386634713aed2fa45d221 (pullrequest created)
worker_1    | [2021-11-16 23:31:39,985: INFO/ForkPoolWorker-2] Sending POST request to https://hooks.slack.com/services/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 (pullrequest created)
worker_1    | [2021-11-16 23:31:40,355: INFO/ForkPoolWorker-2] Request succeeded; response status 200
worker_1    | [2021-11-16 23:31:40,357: INFO/ForkPoolWorker-2] Task nautobot.extras.tasks.process_webhook[3b3b1430-8fb2-4f3f-8287-efdb36d21665] succeeded in 0.43125990001135506s: 'Status 200 returned, webhook successfully processed.'
dolt_1      | 2021-11-16T23:31:40Z INFO [conn 133] ConnectionClosed {}
worker_1    | [2021-11-16 23:31:40,424: INFO/ForkPoolWorker-6] Request succeeded; response status 200
worker_1    | [2021-11-16 23:31:40,426: INFO/ForkPoolWorker-6] Task nautobot.extras.tasks.process_webhook[bd4b3106-3a32-4f04-8f4e-a7f1b4427508] succeeded in 0.49989979999372736s: 'Status 200 returned, webhook successfully processed.'
dolt_1      | 2021-11-16T23:31:40Z INFO [conn 134] ConnectionClosed {}
nautobot_1  | [16/Nov/2021 23:31:40] "POST /plugins/dolt/pull-request/add/ HTTP/1.1" 302 0
dolt_1      | 2021-11-16T23:31:40Z INFO [conn 132] ConnectionClosed {}

In the non-main branch, it shows no webhooks configured: image

When I create a PR on this non-main branch, no webhook fires:

dolt_1      | 2021-11-16T23:27:31Z INFO [conn 112] ConnectionClosed {}
dolt_1      | 2021-11-16T23:27:31Z INFO [conn 111] ConnectionClosed {}
dolt_1      | 2021-11-16T23:27:31Z INFO [conn 113] ConnectionClosed {}
dolt_1      | 2021-11-16T23:27:31Z INFO [conn 114] ConnectionClosed {}
nautobot_1  | [16/Nov/2021 23:27:32] "GET /health/ HTTP/1.1" 201 0
dolt_1      | 2021-11-16T23:27:35Z INFO [conn 115] NewConnection {}
dolt_1      | 2021-11-16T23:27:35Z INFO [conn 116] NewConnection {}
nautobot_1  | [16/Nov/2021 23:27:36] "GET /extras/webhooks/ HTTP/1.1" 200 211004
dolt_1      | 2021-11-16T23:27:36Z INFO [conn 116] ConnectionClosed {}
dolt_1      | 2021-11-16T23:27:36Z INFO [conn 115] ConnectionClosed {}
nautobot_1  | [16/Nov/2021 23:27:37] "GET /health/ HTTP/1.1" 201 0
tim-fiola commented 2 years ago

It's not permitted to create non-versioned objects (like webhooks) on the non-main branch

image

tim-fiola commented 2 years ago

It looks like the rub here is that you have to create a branch from main after you've defined the webhooks in main, then the hooks will come through to the non-main branch:

image

in this scenario the webhooks will fire when the PR is created when the non-main branch is active