Triggering Code Manager with a webhook

This version is no longer supported, maintained, or updated. For current versions, see Puppet Enterprise support lifecycle.

To deploy your code, you can trigger Code Manager by hitting a web endpoint, either through a webhook or a custom script. The webhook, described on this page, is the simplest way to trigger Code Manager.

Custom scripts are a good alternative if you have requirements such as existing continuous integration systems, privately hosted Git repos, or custom notifications. See Creating custom scripts for information about writing a script to trigger Code Manager.

Before you begin, you should already have enabled and configured Code Manager.

Code Manager supports webhooks for GitHub, Bitbucket Server (formerly Stash), Bitbucket, and Team Foundation Server. The Code Manager webhook must only be used by the control repository. It can’t be used by any other repository (for example, other internal component module repositories).

Create a webhook

To set up the webhook to trigger Code Manager to deploy your environments:

  1. Create a custom URL that triggers Code Manager.
  2. Set up the webhook with your Git host.

Create a custom URL

To trigger Code Manager, you’ll need a custom URL composed of:

  • The name of the Puppet master server (for example,
  • The Code Manager port (for example, 8170).
  • The endpoint (/code-manager/v1/webhook/).
  • Any relevant query parameters (for example, type=github).
  • The complete authentication token you generated earlier (token=<TOKEN>), passed with the token query parameter.

Note to GitLab users: Prior to GitLab 8.5.0, GitLab had a character limit on webhooks and would not accept the entire authentication token. If you are using a GitLab version earlier than 8.5.0, either upgrade to the current GitLab version or turn off Code Manager webhook authentication via Hiera with the authenticate_webhook parameter.

Code Manager supports webhooks for GitHub, Bitbucket Server (formerly Stash), Bitbucket, and Team Foundation Server (TFS).

Query parameters

The following query parameters are permitted in the Code Manager webhook. The token query is mandatory, unless you disable authenticate_webhook in Code Manager’s configuration.

  • type: Required. Specifies which type of post body to expect. Accepts:
    • github: GitHub
    • gitlab: GitLab
    • stash: Bitbucket Server (Stash)
    • bitbucket: Bitbucket
    • tfs-git: Team Foundation Server (resource version 1.0 is supported)
  • prefix: Specifies a prefix for converting branch names to environments.
  • token: Specifies the entire PE authorization token.

So, a URL for a GitHub webhook might look like this:<TOKEN>

The URL for a Stash webhook might look something like this:<TOKEN>

With the complete token attached, a GitHub URL looks something like this:

Set up the webhook

Enter the URL you created above into your Git server’s webhook form as the payload URL. The content type for webhooks is JSON.

Exactly how you set up the webhook varies, depending on where your Git repos are hosted. For example, in your GitHub repo, click on Settings > Webhooks to enter the payload URL and set the content type to application/json.

Testing and troubleshooting

To test and troubleshoot your webhook, review the webhook runs logged by your repository host. Each of the major repository hosting services (such as GitHub or Bitbucket) provides a way to review your webhook runs, so check their documentation for instructions.

For other issues, check the Code Manager troubleshooting for some common problems and troubleshooting tips.

Next steps

At this point, your Code Manager setup is complete. Code Manager is ready to deploy your new code into your environments. Commit new code and push it to your control repo. The webhook triggers Code Manager, and your code is deployed.

How helpful was this page?
Puppet sites use proprietary and third-party cookies. By using our sites, you agree to our cookie policy.