Comment on page
A webhook is a POST request sent to a URL. Use webhooks to trigger an action in response to an event such as a repository push.
Webhooks are only available on non-Edge environments (environments running Portainer Server or Portainer Agent, not the Portainer Edge Agent). This is because the tunnel to the Portainer Edge Agent is only opened on-demand, and therefore would mean there is no way to expose a webhook permanently.
From the menu select Applications then select the application that you want to configure the webhook for. Then select the Edit this application button.
Webhooks are only available for applications deployed from a Git repository.
Enable GitOps updates if it is not already enabled and select
Webhookas the Mechanism. When the URL appears, click Copy link. This is the URL used to trigger the webhook.
This example shows how to trigger the webhook:
<form action="https://portainer:9443/api/stacks/webhooks/40ac1662-47c3-4a8e-b148-2a34eb52bb42" method="post">
Redeploy application <input type="submit" />
When triggering a webhook, environment variables can be passed through the endpoint and referenced within the deployment.
Environment variables can not be updated for Pods, only for Deployments.
To specify an environment variable on a webhook, add it as a variable to the URL. For example, to pass a
SERVICE_TAGvariable with the value
To reference the
SERVICE_TAGvariable in your manifest with a fallback to the value
- name: nginx
- containerPort: 80
- name: SERVICE_TAG
Environment variables must already be defined in the manifest - new environment variables cannot be added via the webhook.
When using an application's webhook to redeploy your application, you can tell Portainer to perform a rolling restart of the application rather than a "terminate and restart" redeploy.
This functionality is only available in Portainer Business Edition.
To specify this, use the
rollout-restartparameter in your webhook call:
Valid options are as below:
rollout-restartparameter is not defined, the webhook will redeploy the application in traditional "terminate and restart" behavior.