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 /lib | |
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 'lib')
-rw-r--r-- | lib/api/triggers.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/api/triggers.rb b/lib/api/triggers.rb index 9a4f1cd342f..569598fbd2c 100644 --- a/lib/api/triggers.rb +++ b/lib/api/triggers.rb @@ -12,7 +12,7 @@ module API requires :token, type: String, desc: 'The unique token of trigger' optional :variables, type: Hash, desc: 'The list of variables to be injected into build' end - post ":id/trigger/builds" do + post ":id/(ref/:ref/)trigger/builds" do project = Project.find_with_namespace(params[:id]) || Project.find_by(id: params[:id]) trigger = Ci::Trigger.find_by_token(params[:token].to_s) not_found! unless project && trigger |