mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 12:46:18 +01:00
55 lines
2.0 KiB
Plaintext
55 lines
2.0 KiB
Plaintext
// Module included in the following assemblies:
|
|
//
|
|
// * builds/triggering-builds-build-hooks.adoc
|
|
|
|
:_mod-docs-content-type: PROCEDURE
|
|
[id="builds-using-bitbucket-webhooks_{context}"]
|
|
= Using Bitbucket webhooks
|
|
|
|
link:https://confluence.atlassian.com/bitbucket/manage-webhooks-735643732.html[Bitbucket webhooks] handle the call made by Bitbucket when a repository is updated. Similar to GitHub and GitLab triggers, you must specify a secret. The following example is a trigger definition YAML within the `BuildConfig`:
|
|
|
|
[source,yaml]
|
|
----
|
|
type: "Bitbucket"
|
|
bitbucket:
|
|
secretReference:
|
|
name: "mysecret"
|
|
----
|
|
|
|
The payload URL is returned as the Bitbucket Webhook URL by the `oc describe` command, and is structured as follows:
|
|
|
|
.Example output
|
|
[source,terminal]
|
|
----
|
|
https://<openshift_api_host:port>/apis/build.openshift.io/v1/namespaces/<namespace>/buildconfigs/<name>/webhooks/<secret>/bitbucket
|
|
----
|
|
|
|
.Prerequisites
|
|
|
|
* `system:unauthenticated` has access to the `system:webhook` role in the required namespaces. Or, `system:unauthenticated` has access to the `system:webhook` cluster role.
|
|
|
|
.Procedure
|
|
|
|
. Configure a Bitbucket Webhook.
|
|
|
|
.. Get the webhook URL by entering the following command:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ oc describe bc <name>
|
|
----
|
|
|
|
.. Copy the webhook URL, replacing `<secret>` with your secret value.
|
|
|
|
.. Follow the link:https://confluence.atlassian.com/bitbucket/manage-webhooks-735643732.html[Bitbucket setup instructions] to paste the webhook URL into your Bitbucket repository settings.
|
|
|
|
. Given a file containing a valid JSON payload, such as `payload.json`, you can
|
|
manually trigger the webhook by entering the following `curl` command:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ curl -H "X-Event-Key: repo:push" -H "Content-Type: application/json" -k -X POST --data-binary @payload.json https://<openshift_api_host:port>/apis/build.openshift.io/v1/namespaces/<namespace>/buildconfigs/<name>/webhooks/<secret>/bitbucket
|
|
----
|
|
+
|
|
The `-k` argument is only necessary if your API server does not have a properly signed certificate.
|