Creating webhooks

For manually-created Control repositories, you must create a webhook so that Code Genie can detect pull request activity and trigger automated scans and reviews

Before you begin

Before you begin, ensure that you have:

  • Administrator access to the Control repository in Gitea.
  • Created a Control repository manually.
  • Read Code Genie documentation.
  • Confirmed that the Code Genie service is running and accessible from the Gitea server's network.

About this task

A webhook is an HTTP callback that Gitea triggers automatically when repository events occur. When an event matches your configured trigger, Gitea sends a POST request with a JSON payload to the Code Genie target URL. You can filter triggers by event type and branch pattern, giving you precise control over which pull request activities notify Code Genie.

Important:
Automatic configuration of the webhook only applies to Control repositories created through the Loop creation process. If you create a Control repository manually, you must create the webhook yourself, as described in this procedure. You must also configure branch protection rules and create the .devops-loop/code-config.jsonc file for Code Genie to work correctly.

Procedure

  1. Navigate to your Control repository in Gitea and click Settings.
  2. In the left navigation panel, click Webhooks under Settings.
  3. Click Add Webhook and select Gitea from the drop-down list.
  4. Configure the webhook with the following values.
    • Target URL: http://devops-code-container-mgr:3005/api/pull-request
    • HTTP Method: POST
    • POST Content Type: application/json
  5. Under Trigger On, select Custom Events.
  6. In the Pull Request Events section, select the following check boxes.
    • Pull Request — fires when a pull request is opened, closed, reopened, or edited.
    • Pull Request Synchronized — fires when new commits are pushed to an open pull request.
  7. In the Branch Filter field, enter * to apply the webhook to all branches.
    To restrict to specific branches, use a glob pattern such as master or {master,release*}.
  8. Click Add Webhook to save the configuration.
  9. Confirm that the webhook appears in the Webhooks list with a green status indicator.

Results

You have created a webhook on the Control repository. Gitea will now send a POST request to Code Genie each time a pull request is opened or synchronized on the repository.

What to do next

After creating the webhook, you must complete the remaining manual configuration steps before Code Genie can scan pull requests:

  • Configure branch protection rules for the main branch.
  • Create the .devops-loop/code-config.jsonc file in the Control repository to enable Trivy scanning.