Docker Hub triggers

You can define and manage DockerHub triggers in Codefresh.

Create a new DockerHub trigger in Codefresh UI

To add a new DockerHub trigger, navigate to Codefresh Pipeline Configuration view and expand Triggers section. Press the Add Trigger button and select a Registry trigger type to add.

Adding new Trigger dialog

Fill the following information:

  • Registry Provider - select DockerHub.
  • User/Organization Name - put DockerHub user name or organization name here.
  • Image Repository Name - DockerHub image repository name.
  • Action - select Push Image action.
  • Tag - optional filter to specify which image tags will trigger pipeline execution: Re2 regular expression.

Add Registry Trigger

Set up DockerHub Webhook

Currently Codefresh does not support automatically setting up a Docker Hub webhook. You need to do this manually. Press the Next button and see detailed instructions with URL links and secrets of how-to setup a Docker Hub Webhook.

Add Webhook

  1. Copy Endpoint URL
  2. Visit DockerHub image settings page following link in help
  3. Add a new DockerHub Webhook with previously copied Endpoint URL

Triggering Codefresh pipeline with Docker Hub push

Now, every time you push a new Docker image to selected Docker Hub repository, manually, with Codefresh or any other CI/CD tool, Codefresh will trigger execution of all pipelines associated with this Docker Hub Push trigger event.

Manage Docker Hub triggers with Codefresh CLI

It is possible to use codefresh command line client (CLI) to manage Docker Hub pipeline triggers.

Docker Hub Trigger

It is possible to trigger Codefresh CD pipeline(s) when a new Docker image pushed into Docker Hub.

You can use Codefresh CLI to set up a Codefresh trigger for Docker Hub.

Create Docker Hub trigger-event

First, create a trigger-event for every Docker Hub image, you would like to setup a Codefresh trigger.

# create DockerHub trigger event for codefresh/fortune
codefresh create trigger-event --type registry --kind dockerhub --value namespace=codefresh --value name=fortune --value action=push

# on success trigger-event UID will be printed out
Trigger event: registry:dockerhub:codefresh:fortune:push:107e9db97062 was successfully created.

Set up Docker Hub webhook

Currently, an additional manual action is required to bind DockerHub push image event to the Codefresh trigger-event.

# get trigger-event details for previously created trigger-event
codefresh get trigger-event -o yaml registry:dockerhub:codefresh:fortune:push:107e9db97062

… command output:

uri: 'registry:dockerhub:codefresh:fortune:push:107e9db97062'
type: registry
kind: dockerhub
public: false
secret: aGao5weuez2G6WF9
status: active
endpoint: >-
description: Docker Hub codefresh/fortune push event
help: >-
  Docker Hub webhooks fire when an image is built in, pushed or a new tag is
  added to, your repository.

  Configure Docker Hub webhooks on

  Add following Codefresh Docker Hub webhook endpoint
  1. Copy endpoint URL
  2. Visit DockerHub settings page
  3. Add a new Webhook with previously copied endpoint URL.

Set up pipeline trigger

Now, lets set up a new pipeline trigger, linking previously defined DockerHub push codefresh/fortune trigger-event to one or more Codefresh pipelines.

# create trigger, linking trigger-event UID to the pipeline UID
codefresh create trigger "registry:dockerhub:codefresh:fortune:push:107e9db97062" 7a5622e4b1ad5ba0018a3c9c

# create another trigger, linking the same trigger-event to another pipeline
codefresh create trigger "registry:dockerhub:codefresh:fortune:push:107e9db97062" 4a5634e4b2cd6baf021a3c0a

From now on, Codefresh will trigger pipeline execution when new codefresh/fortune image is pushed to the DockerHub.

DockerHub Event payload

The following variables will be available for any Codefresh pipeline linked to a DockerHub trigger-event:

  • EVENT_NAMESPACE - DockerHub namespace (alias organization).
  • EVENT_NAME - DockerHub image name (alias repository).
  • EVENT_TAG - Docker image tag.
  • EVENT_PUSHER - user who pushed this Docker image.
  • EVENT_PUSHED_AT - timestamp for push event.
  • EVENT_PAYLOAD - original DockerHub Webhook JSON payload.

Triggers in pipelines
Creating pipelines