diff options
author | Rémy Coutable <remy@rymai.me> | 2016-11-15 20:37:04 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-11-15 20:37:04 +0000 |
commit | 46eb0ebfd277cdbbbe68d008df6d57ef433e9a7d (patch) | |
tree | 4b78b98536a6b13882f4c34cd4cee611bc220770 /doc | |
parent | d5cd0d67f1504d773500fd1605a05ed6c1320cb3 (diff) | |
parent | ff8194e0ec16092419862011d7cc048baa149c42 (diff) | |
download | gitlab-ce-46eb0ebfd277cdbbbe68d008df6d57ef433e9a7d.tar.gz |
Merge branch '23584-triggering-builds-from-webhooks' into 'master'
Add ref parameter for triggering builds with gitlab webhook from other project.
Currently GitLab can trigger builds from external tools like curl.
But there is no way to trigger builds with webhook from another GitLab project.
Executing webhook like `/projects/:id/trigger/builds?token=TOKEN&ref=master` results in such message from server:
```
400 No builds created
```
Problem is the ref from request body takes precedence of the ref from query string.
System tries to trigger build for nonexistent branch instead of `master`.
This is the feature of the Grape framework used to build GitLab api.
This MR adds optional `ref` parameter into the api url:
```
/projects/:id/ref/:ref/trigger/builds?token=TOKEN
```
This will lead that the ref in the url will have precedence of the ref inside request body.
This solution provides compatibility with current API urls.
Closes #23584
See merge request !7022
Diffstat (limited to 'doc')
-rw-r--r-- | doc/ci/triggers/README.md | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/doc/ci/triggers/README.md b/doc/ci/triggers/README.md index 84048f1d25f..cf7c55f75f2 100644 --- a/doc/ci/triggers/README.md +++ b/doc/ci/triggers/README.md @@ -58,6 +58,22 @@ below. See the [Examples](#examples) section for more details on how to actually trigger a rebuild. +## Trigger a build from webhook + +> Introduced in GitLab 8.14. + +To trigger a build from webhook of another project you need to add the following +webhook url for Push and Tag push events: + +``` +https://gitlab.example.com/api/v3/projects/:id/ref/:ref/trigger/builds?token=TOKEN +``` + +> **Note**: +- `ref` should be passed as part of url in order to take precedence over `ref` + from webhook body that designates the branchref that fired the trigger in the source repository. +- `ref` should be url encoded if contains slashes. + ## Pass build variables to a trigger You can pass any number of arbitrary variables in the trigger API call and they @@ -169,6 +185,14 @@ curl --request POST \ https://gitlab.example.com/api/v3/projects/9/trigger/builds ``` +### Using webhook to trigger builds + +You can add the following webhook to another project in order to trigger a build: + +``` +https://gitlab.example.com/api/v3/projects/9/ref/master/trigger/builds?token=TOKEN&variables[UPLOAD_TO_S3]=true +``` + ### Using cron to trigger nightly builds Whether you craft a script or just run cURL directly, you can trigger builds |