Triggering Code Manager with a webhook
To deploy your code, you can trigger Code Manager by hitting a web endpoint, either through a webhook or a custom script. Webhooks are the simplest way to trigger Code Manager.
Create a Code Manager webhook
To set up the webhook to trigger environment deployments, you must create a custom URL, and then set up the webhook with your Git host.
Create a custom URL
Create a custom URL to allow communication between your Git host and Code Manager.
|Your primary server's DNS name
|The port used by Code Manager
|The Code Manager webhook endpoint
|Required and optional Code Manager webhook query parameters
token parameter is required unless you
authenticate_webhook. With the
token parameter, the valid URL format
parameter, the valid URL format
Code Manager webhook query parameters
You can use these query parameters in your the Code Manager webhook URL.
Required. Specifies the type of
|Specify the value corresponding with your Git host:
Conditionally required. Specifies a prefix for converting branch names to
Important: Required if you used prefixing when Configuring sources. If your sources use prefixing and you do not specify this parameter, Code Manager can't correctly locate or deploy environments, or translate branch names to valid environment names.
Conditionally required. Specifies the entire PE authorization token to use for code deployments.
To get a token, you can Request an authentication token for deployments.
Important: Required unless you disabled
authenticate_webhook in your Code Manager configuration.
Set up the Code Manager webhook on your Git host
In your Git server’s webhook form, enter your custom URL as the payload URL.
The content type for Code Manager webhooks is JSON.
The specific steps for setting up a webhook depends on your Git host. Refer to your Git host's documentation for instructions.
For example, in a GitHub repo, click , enter the payload URL, and enter application/json as the content type.
After setting up your webhook, you've finished setting up Code Manager. From now on, when you commit new code and push it to your control repo, the webhook triggers Code Manager to deploy your code. You can also use the POST /v1/webhook endpoint to manually trigger your webhook.
Troubleshoot a Code Manager webhook
To troubleshoot your webhook, you can review your Git host's logs. Refer to your Git host's documentation for information about their logs and their suggestions for resolving common webhook issues.
Deployments triggered by a webhook in Stash/Bitbucket, GitLab, or GitHub are governed by authentication and hit the POST /v1/webhook endpoint for each service type.
If you are using a GitLab version older than 8.5.0, Code Manager's webhook authentication doesn't work because of the length of the authentication token. To use the webhook with GitLab, either disable authentication or update GitLab. If you disable webhook authentication, it is disabled only for the POST /v1/webhook endpoint. It is not possible to disable authentication for the POST /v1/deploys or GET /v1/deploys/status endpoints.
tail -f /var/log/puppetlabs/puppetserver/puppetserver.log
Watch the log closely for errors and information messages when you trigger the webhook.
puppetserver.log file is the only location these errors appear. If
you cannot determine the problem with your webhook this way, manually deploy to the
POST /v1/deploys endpoint while monitoring the
console-services.log file, as described in Troubleshooting Code Manager.
For other Code Manager issues, refer to Troubleshooting Code Manager.