Skip to content

feat(webhook): add Forgejo CLI setup#2764

Open
SecKatie wants to merge 1 commit into
tektoncd:mainfrom
SecKatie:issue-2755-forgejo-cli-webhook
Open

feat(webhook): add Forgejo CLI setup#2764
SecKatie wants to merge 1 commit into
tektoncd:mainfrom
SecKatie:issue-2755-forgejo-cli-webhook

Conversation

@SecKatie
Copy link
Copy Markdown

@SecKatie SecKatie commented Jun 4, 2026

📝 Description of the Change

Adds Forgejo to the CLI webhook setup path used by tkn pac create repo and tkn pac webhook add.

This PR:

  • adds forgejo to webhook provider selection and detection
  • creates Forgejo repository webhooks with the vendored Forgejo SDK
  • configures the Forgejo events PAC already handles: push, pull_request, and issue_comment
  • updates Forgejo docs with CLI setup and token requirements
Added Forgejo support to `tkn pac create repo` and `tkn pac webhook add`.

🔗 Linked GitHub Issue

Fixes #2755

🧪 Testing Strategy

  • Unit tests
  • Integration tests
  • End-to-end tests
  • Manual testing
  • Not Applicable

Ran:

make check

🤖 AI Assistance

AI assistance can be used for various tasks, such as code generation,
documentation, or testing.

Please indicate whether you have used AI assistance
for this PR and provide details if applicable.

  • I have not used any AI assistance for this PR.
  • I have used AI assistance for this PR.

Used AI assistance to help implement the Forgejo CLI webhook setup, tests, docs, and PR preparation. I reviewed the generated code and ran the local checks listed above.

Important

Slop will be simply rejected, if you are using AI assistance you need to make sure you
understand the code generated and that it meets the project standards. you
need at least know how to run the code and deploy it (if needed). See
startpaac to make it easy
to deploy and test your code changes.

If the majority of the code in this PR was generated by an AI, please add a Co-authored-by trailer to your commit message.
For example:

Co-authored-by: Claude noreply@anthropic.com

✅ Submitter Checklist

  • 📝 My commit messages are clear, informative, and follow the project How to write a git commit message guide. The Gitlint linter ensures in CI it is properly validated
  • ✨ I have ensured my commit message prefix, for example fix: or feat:, matches the Type of Change I selected above.
  • ♽ I have run make test and make lint locally to check for and fix any
    issues. For an efficient workflow, I have considered installing
    pre-commit and running pre-commit install to
    automate these checks.
  • 📖 I have added or updated documentation for any user-facing changes.
  • 🧪 I have added sufficient unit tests for my code changes.
  • 🎁 I have added end-to-end tests where feasible. See README for more details.
  • 🔎 I have addressed any CI test flakiness or provided a clear reason to bypass it.
  • If adding a provider feature, I have filled in the following and updated the provider documentation:
    • GitHub App
    • GitHub Webhook
    • Gitea/Forgejo
    • GitLab
    • Bitbucket Cloud
    • Bitbucket Data Center

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Jun 4, 2026

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: SecKatie / name: Katie Mulliken (2fe600d)

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for configuring Forgejo webhooks via the CLI, including updated documentation, a new forgejoConfig implementation, and corresponding unit tests. Feedback points out that parsing SSH repository URLs in forgejoInstanceURL can cause an error that blocks the setup process, and suggests ignoring the error to gracefully fall back to an empty default URL.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +109 to +112
defaultURL, err := forgejoInstanceURL(repoURL)
if err != nil {
return err
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

If the repository URL is an SSH URL (e.g., git@forgejo.example.com:owner/repo.git), forgejoInstanceURL will return an error because it cannot parse the scheme and host. Returning this error immediately blocks the user from proceeding with the CLI setup.

Instead of returning the error and aborting, we should handle it gracefully by falling back to an empty default URL so the user can still manually input their Forgejo URL.

Suggested change
defaultURL, err := forgejoInstanceURL(repoURL)
if err != nil {
return err
}
defaultURL, _ := forgejoInstanceURL(repoURL)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Will look into this and amend the commit!

Copy link
Copy Markdown
Author

@SecKatie SecKatie Jun 4, 2026

Choose a reason for hiding this comment

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

Okay this is interesting feedback because ssh urls are not even supported by the admission webhook:

Error: admission webhook "validation.pipelinesascode.tekton.dev" denied the request: URL scheme must be http or https

This error with the admission webhook hits before we even get to this line.

@SecKatie SecKatie force-pushed the issue-2755-forgejo-cli-webhook branch from 2fe600d to ffd287b Compare June 5, 2026 01:03
Comment thread pkg/cli/webhook/forgejo.go
@theakshaypant
Copy link
Copy Markdown
Member

/ok-to-test

@SecKatie SecKatie force-pushed the issue-2755-forgejo-cli-webhook branch from ffd287b to d0cd587 Compare June 5, 2026 01:33
Comment thread pkg/cli/webhook/forgejo.go
Comment thread pkg/cli/webhook/forgejo_test.go Outdated
Comment thread pkg/cli/webhook/forgejo_test.go Outdated
case strings.Contains(url, "bitbucket-cloud"):
providerName = "bitbucket-cloud"
case strings.Contains(url, "forgejo"):
providerName = "forgejo"
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.

not something you need to address but I think GetProviderName is very fragile with hosted instance, names can be anything...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

100% agree. Just couldn't think of any other "definitive" signal here.

Comment thread pkg/cli/webhook/forgejo.go Outdated
@SecKatie SecKatie force-pushed the issue-2755-forgejo-cli-webhook branch 3 times, most recently from a2afb61 to 4eef949 Compare June 5, 2026 13:39
Support Forgejo in the CLI webhook setup path for `tkn pac create repo` and `tkn pac webhook add`. This lets users create the Repository CR, secret, and Forgejo webhook through the same flow as the other supported webhook providers.

Use the existing vendored Forgejo SDK, configure the Forgejo events that Pipelines-as-Code already handles, and document the token requirements for CLI setup. Fixes tektoncd#2755.

Co-Authored-By: GPT 5.5 <codex@openai.com>
Signed-off-by: Katie Mulliken <mulliken@redhat.com>
@SecKatie SecKatie force-pushed the issue-2755-forgejo-cli-webhook branch from 4eef949 to a6e6012 Compare June 5, 2026 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ask: support Forgejo in tkn pac create repo and webhook add

4 participants