Artifactory triggers

Trigger Codefresh pipelines from Artifactory

Define and manage Artifactory pipeline triggers with the Codefresh UI. This allows you to trigger Codefresh pipelines when an Artifactory event occurs (i.e. a new Docker image is uploaded).

Manage Artifactory Triggers with Codefresh UI

The process involves two parts:

  1. Creating a trigger in Codefresh. This will result in a special Codefresh webhook URL
  2. Activating the webhook plugin in Artifactory and setting it up to call the Codefresh URL

NOTE
Make sure that you have admin access to your Artifactory instance in order to setup its webhook plugin.

Create a new Artifactory trigger

To add a new Artifactory trigger, navigate to a Codefresh Pipeline Configuration view and expand the 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 JFrog.
  • Repository Name - put JFrog name of repository.
  • Docker Image Name - put name of Docker image.
  • Action - select Push Image action.
  • Tag - optional filter to specify which image tags will trigger pipeline execution: Re2 regular expression.

Artifactory Registry settings

Click next and a new Dialog will appear that shows you the Codefresh webhook URL. Copy it to your clipboard.

Codefresh webhook URL

Now we must set JFrog Artifactory to call this URL when an event takes place.

Set up JFrog Artifactory webhook plugin

The webhook functionality in JFrog artifactory comes in plugin. You can read detailed documentation for JFrog plugins but in summary:

  • The file webhook.groovy needs to be copied to ARTIFACTORY_HOME/etc/plugins (the plugin itself)
  • A file webhook.config.json should also be placed in the same folder (the plugin setup)

Here is an example for Codefresh.

webhook.config.json

{
 "webhooks": {
   "mywebhook": {
     "url": "https://g.codefresh.io/nomios/jfrog?account=2dfdf89f235bfe&sefgt=EvQf9bBS55UPekCu",
     "events": [
       "docker.tagCreated"
     ]
   }
 },
 "debug": false,
 "timeout": 15000
}

Trigger a Codefresh pipeline with an Artifactory push

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

Triggers in pipelines
Creating pipelines