Skip to content

refactor: migrate webhooks to scmclients - #1734

Merged
jenkins-x-bot merged 1 commit into
jenkins-x:mainfrom
spring-financial-group:refactor/MigrateWebhooks
Nov 17, 2026
Merged

jenkins-x-bot merged 1 commit into
jenkins-x:mainfrom
spring-financial-group:refactor/MigrateWebhooks

Conversation

@Skisocks

Copy link
Copy Markdown
Member

Changelog

  • webhooks builds its clients once at startup with scmclients.New rather than rebuilding the go-scm client, resetting git credentials and replacing the shared ClientAgent on every request.
  • The periodic agent is given its SCM client up front. Its util.GetSCMClient fallback is removed.
  • Remove util.GetSCMClient, util.AddAuthToSCMClient and util.GetSCMToken, which no longer have callers.
  • The webhooks --bot-name flag is now honoured (it was ignored previously).

Context

Follow-up to #1729, migrating the last process onto scmclients. Behaviour changes:

  • A missing token now fails at startup (previously every webhook returned a 500).
  • Azure DevOps API calls use go-scm's Basic auth instead of Bearer, matching keeper and poller since refactor: migrate keeper, poller and foghorn to scmclients #1729.
  • File browsers pick up a rotated GIT_TOKEN_PATH. Previously they kept the token from the first request.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the shared SCM client migration.

No open issues 🎉

What changed in this PR

Migrates webhooks to shared scmclients initialization, continuing the client consolidation from #1729 and removing per-request client setup.

Changes:

  • Initialize webhook clients once at startup, honour --bot-name, and support token rotation in file browsers.
  • Inject the periodic agent’s SCM client directly and remove obsolete client and authentication helpers.
  • Update tests to use shared clients and clean up their resources.
File Description
test/​e2e/​helpers.go Remove redundant authentication setup.
pkg/​webhook/​webhook.go Initialize and reuse shared clients at startup.
pkg/​webhook/​webhook_test.go Adopt shared clients and add cleanup.
pkg/​webhook/​events.go Remove bespoke file-browser initialization.
pkg/​webhook/​create_agent_integration_test.go Use shared clients with registered cleanup.
pkg/​util/​scmclient.go Remove obsolete SCM client and token helpers.
pkg/​util/​scmclient_test.go Remove tests for deleted token helpers.
pkg/​plugins/​trigger/​periodic.go Remove fallback SCM client creation.

Review effort: Balanced

@Skisocks
Skisocks marked this pull request as ready for review November 17, 2026 11:41
@Skisocks

Copy link
Copy Markdown
Member Author

/cc @msvticket

@msvticket msvticket left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

I note that scmclient.go is exported to lighthouse-client: https://github.com/jenkins-x/lighthouse-client/blob/main/pkg/util/scmclient.go
So in principle this is a breaking change of lighthouse-client. But I don't see that anything is using those methods outside of lighthouse, so it's fine.

There are stuff in pkg/util that should be public, but I think neither scmclient nor scmclients should be. Maybe that is something you can address when you continue your work on lighthouse.

https://github.com/jenkins-x/lighthouse-client/blob/main/recreate.sh#L20

@jenkins-x-bot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: msvticket

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jenkins-x-bot

Copy link
Copy Markdown
Contributor

Failed to merge this PR at Tue, 17 Nov 2026 12:11:25 UTC due to:

failed merging [1734]: [Method Not Allowed]

@jenkins-x-bot
jenkins-x-bot merged commit 19d712d into jenkins-x:main Nov 17, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants