Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-11-15 23:37:04 +0300
committerRémy Coutable <remy@rymai.me>2016-11-15 23:37:04 +0300
commit46eb0ebfd277cdbbbe68d008df6d57ef433e9a7d (patch)
tree4b78b98536a6b13882f4c34cd4cee611bc220770 /app
parentd5cd0d67f1504d773500fd1605a05ed6c1320cb3 (diff)
parentff8194e0ec16092419862011d7cc048baa149c42 (diff)
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 'app')
-rw-r--r--app/helpers/triggers_helper.rb8
-rw-r--r--app/views/projects/triggers/index.html.haml20
2 files changed, 25 insertions, 3 deletions
diff --git a/app/helpers/triggers_helper.rb b/app/helpers/triggers_helper.rb
index 8cad994d10f..c41181bab3d 100644
--- a/app/helpers/triggers_helper.rb
+++ b/app/helpers/triggers_helper.rb
@@ -1,5 +1,9 @@
module TriggersHelper
- def builds_trigger_url(project_id)
- "#{Settings.gitlab.url}/api/v3/projects/#{project_id}/trigger/builds"
+ def builds_trigger_url(project_id, ref: nil)
+ if ref.nil?
+ "#{Settings.gitlab.url}/api/v3/projects/#{project_id}/trigger/builds"
+ else
+ "#{Settings.gitlab.url}/api/v3/projects/#{project_id}/ref/#{ref}/trigger/builds"
+ end
end
end
diff --git a/app/views/projects/triggers/index.html.haml b/app/views/projects/triggers/index.html.haml
index f6e0b0a7c8a..6e5dd1b196d 100644
--- a/app/views/projects/triggers/index.html.haml
+++ b/app/views/projects/triggers/index.html.haml
@@ -76,6 +76,16 @@
script:
- "curl -X POST -F token=TOKEN -F ref=REF_NAME #{builds_trigger_url(@project.id)}"
%h5.prepend-top-default
+ Use webhook
+
+ %p.light
+ Add the following webhook to another project for Push and Tag push events.
+ The project will be rebuilt at the corresponding event.
+
+ %pre
+ :plain
+ #{builds_trigger_url(@project.id, ref: 'REF_NAME')}?token=TOKEN
+ %h5.prepend-top-default
Pass build variables
%p.light
@@ -83,10 +93,18 @@
%code variables[VARIABLE]=VALUE
to an API request. Variable values can be used to distinguish between triggered builds and normal builds.
- %pre.append-bottom-0
+ With cURL:
+
+ %pre
:plain
curl -X POST \
-F token=TOKEN \
-F "ref=REF_NAME" \
-F "variables[RUN_NIGHTLY_BUILD]=true" \
#{builds_trigger_url(@project.id)}
+ %p.light
+ With webhook:
+
+ %pre.append-bottom-0
+ :plain
+ #{builds_trigger_url(@project.id, ref: 'REF_NAME')}?token=TOKEN&variables[RUN_NIGHTLY_BUILD]=true