1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-07 00:48:01 +01:00
Files
openshift-docs/modules/builds-using-bitbucket-webhooks.adoc
2023-10-30 10:13:25 -04:00

51 lines
1.8 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 the previous 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
----
.Procedure
. To configure a Bitbucket Webhook:
.. Describe the 'BuildConfig' to get the webhook URL:
+
[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 with `curl`:
+
[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.