Custom Webhooks Examples

JFrog Platform Administration Documentation

Content Type
Administration / Platform
ft:sourceType
Paligo

The following are some examples of custom webhooks for various services.

GitHub Example

    {
        "key": "subscriptionOnGithub",
        "description": "some custom webhook subscription",
        "enabled": true,
        "event_filter": {
            "criteria": {
                "anyLocal": true
            },
            "domain": "artifact",
            "event_types": [
                "deployed"
            ]
        },
        "handlers": [
            {
                "handler_type": "custom-webhook",
                "url": "https://api.github.com//<username>/<reponame>/dispatches",
                "payload": "{\"event_type\": \"someEventType\"}",
                "secrets": [
                    {
                        "name": "token",
                        "value": "XXX"
                    }
                ],
                "http_headers": [
                    {
                        "name": "Authorization",
                        "value": "Bearer {{ .secrets.token }}"
                    }
                ]
            }
        ]
    }
180126441.png

GitLab Example

{
    "key": "subscriptionOnGitlab",
    "description": "some custom webhook subscription",
    "enabled": true,
    "event_filter": {
        "domain": "artifact",
        "event_types": [
            "deployed"
        ],
        "criteria": {
            "anyLocal": true,
            "anyRemote": false,
            "includePatterns": [],
            "excludePatterns": [],
            "repoKeys": []
        }
    },
    "handlers": [
        {
            "handler_type": "custom-webhook",
            "url": "http://<gitlaburl>/api/v4/projects/2/ref/main/trigger/pipeline",
            "secrets": [
                {
                    "name": "privatetoken",
                    "value": "XXXXX"
                },
                {
                    "name": "accesstoken",
                    "value": "XXXXXX"
                },
                {
                    "name": "token",
                    "value": "XXXXXXX"
                }
            ],
            "http_headers": [
                {
                    "name": "PRIVATE-TOKEN",
                    "value": "{{ .secrets.privatetoken  }}"
                },
                {
                    "name": "Content-Type",
                    "value": "application/x-www-form-urlencoded"
                }
            ],
            "payload": "token={{ .secrets.token }}&variables[TEST_VAR_CHECKSUM]={{ .data.sha256 }}&variables[ACCESS_TOKEN]={{ .secrets.accesstoken }}"
        }
    ]
}

Jenkins Example

{
    "key": "subscriptionOnJenkins",
    "description": "some custom webhook subscription",
    "enabled": true,
    "event_filter": {
        "criteria": {
            "anyLocal": true
        },
        "domain": "artifact",
        "event_types": [
            "deployed"
        ]
    },
    "handlers": [
        {
            "handler_type": "custom-webhook",
            "url": "http://<jenkinsurl>/job/test/buildWithParameters",
            "secrets": [
                {
                    "name": "token",
                    "value": "mytoken"
                },
                {
                    "name": "restapitoken",
                    "value": "XXXXX"
                }
            ],
            "http_headers": [
                {
                    "name": "Content-Type",
                    "value": "application/x-www-form-urlencoded"
                },
                {
                    "name": "Authorization",
                    "value": "Basic {{ .secrets.restapitoken }}"
                }
            ],
            "payload": "token={{ .secrets.token }}&sha256={{ .data.sha256 }}"
        }
    ]
}

Slack Integration Example

{
  "key": "customwebhook",
  "description": "notify slack channel at artifact deploy",
  "enabled": true,
  "event_filter": {
    "domain": "artifact",
    "event_types": [
      "deployed"
    ],
    "criteria": {
      "anyLocal": true,
      "anyRemote": false,
      "excludePatterns": [],
      "includePatterns": [],
      "repoKeys": []
    }
  },
  "handlers": [
    {
      "handler_type": "custom-webhook",
      "url": "https://hooks.slack.com/services/XXXX",
      "payload": "{\"text\": \"Hello from custom webhook triggered by event type {{ .type }}\"}",
      "http_headers": [
        {
          "name": "Content-type",
          "value": "application/json"
        }
      ]
    }
  ]
}