mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 12:46:18 +01:00
56 lines
1.7 KiB
Plaintext
56 lines
1.7 KiB
Plaintext
// Module included in the following assemblies:
|
|
//
|
|
// * assembly/builds
|
|
|
|
[id="builds-using-gitlab-webhooks-{context}"]
|
|
= Using GitLab webhooks
|
|
|
|
link:https://docs.gitlab.com/ce/user/project/integrations/webhooks.html[GitLab webhooks]
|
|
handle the call made by GitLab when a repository is updated. As with the GitHub
|
|
triggers, you must specify a `secret`. The following example is
|
|
a trigger definition YAML within the `BuildConfig`:
|
|
|
|
[source,yaml]
|
|
----
|
|
type: "GitLab"
|
|
gitlab:
|
|
secretReference:
|
|
name: "mysecret"
|
|
----
|
|
|
|
The payload URL is returned as the GitLab Webhook URL by the `oc describe` command
|
|
(see Displaying Webhook URLs), and is structured as follows:
|
|
|
|
----
|
|
http://<openshift_api_host:port>/oapi/v1/namespaces/<namespace>/buildconfigs/<name>/webhooks/<secret>/gitlab
|
|
----
|
|
|
|
.Procedure
|
|
|
|
. To configure a GitLab Webhook:
|
|
|
|
.. Describe the `BuildConfig` to get the webhook URL:
|
|
+
|
|
----
|
|
$ oc describe bc <name>
|
|
----
|
|
|
|
.. Copy the webhook URL, replacing `<secret>` with your secret value.
|
|
|
|
.. Follow the link:https://docs.gitlab.com/ce/user/project/integrations/webhooks.html#webhooks[GitLab setup instructions]
|
|
to paste the webhook URL into your GitLab repository settings.
|
|
|
|
. Given a file containing a valid JSON payload, such as `payload.json`, you can
|
|
manually trigger the webhook with `curl`:
|
|
+
|
|
----
|
|
$ curl -H "X-GitLab-Event: Push Hook" -H "Content-Type: application/json" -k -X POST --data-binary @payload.json https://<openshift_api_host:port>/oapi/v1/namespaces/<namespace>/buildconfigs/<name>/webhooks/<secret>/gitlab
|
|
----
|
|
+
|
|
The `-k` argument is only necessary if your API server does not have a properly
|
|
signed certificate.
|
|
|
|
.Additional resources
|
|
|
|
* link:https://docs.gitlab.com/ce/user/project/integrations/webhooks.html[GitLab]
|