Overview
CircleCI launched a feature that enables organizations to harness the functionality of GitHub Apps for triggering builds. This functions even if the organization was originally set up as GitHub OAuth. Customers do not need to migrate to use this feature. This is achieved by granting CircleCI both GitHub App and GitHub OAuth App permissions.
How does this work?
Webhooks serve as a bridge, connecting a platform (like CircleCI, a custom API, or a third-party service) to a continuous stream of future events. Establishing an inbound webhook as a custom trigger on CircleCI allows a third-party service to initiate a CircleCI pipeline. Essentially, any service capable of sending a webhook or executing a curl request can trigger a CircleCI pipeline.
Setting up Custom Webhooks
-
In the CircleCI web app select Projects in the sidebar.
-
Find your project in the list, select the ellipsis (), select Project Settings, and select Pipelines in the sidebar.
-
If there is already a pipeline set up and it uses the desired YAML configuration file, proceed to the Triggers step below (step 5). If not, select Set up pipeline. If there is a Connect button, select it and follow the steps to install the CircleCI GitHub App into your GitHub organization.
-
Name the new pipeline and select the repository where the CircleCI YAML configuration file is stored. Enter the file path (including the .circleci directory). The file path can be different than .circleci/config.yml(for example, .circleci/webhook.yml ). Save the pipeline.
-
Select Triggers in the sidebar.
-
Select Add Trigger.
-
Select Custom Webhook from the dropdown menu.
-
Select Next.
-
Complete the form fields and options:
-
Enter a descriptive name for the trigger. For example, if you are setting up a custom webhook to run pipelines on events from Datadog, enter "Datadog" here.
-
(Optional) Add a description.
-
In the field "Pipeline to run", at the bottom of the page, select the pipeline that you created in the step above.
-
Enter the branch to use to fetch your config file when a Custom Webhook is received.
-
Enter the branch to use to check out your code when using the checkout step in config. If your config is stored in the same repository as your code, then your Config branch and your Checkout branch should be the same.
-
-
Select Save.
-
You will see a webhook endpoint URL and secret. You can use these to set up your webhook trigger from your external source. Copy the Webhook URL and use it in your trigger source appended with the secret.
Note :The secret will not be shown again so be sure to copy the URL before clicking "Done".The secret will not be shown again so be sure to copy the URL before clicking Done. -
You can now test your custom webhook trigger with curl. To trigger your pipeline, copy and paste the following sample request and replace <your-URL> and <your-secret> with the URL and secret that you generated in the previous step. Note: When triggering via curl, you must use a POST request with content-type: application/json.
curl -X POST -H "content-type: application/json" 'https://internal.circleci.com/private/soc/e/<your-URL>?secret=<your-secret>'
See our community forum for more details or how to use this functionality with a 3rd party service like DockerHub.
Comments
Article is closed for comments.