Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
de518e12
Commit
de518e12
authored
Mar 20, 2017
by
George Andrinopoulos
Committed by
Rémy Coutable
Mar 20, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow dot in branch name in trigger/builds endpoint in API
parent
9bfff603
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
17 deletions
+49
-17
changelogs/unreleased/29438-fix-trigger-webhook-for-ref-with-dot.yml
...unreleased/29438-fix-trigger-webhook-for-ref-with-dot.yml
+4
-0
lib/api/triggers.rb
lib/api/triggers.rb
+1
-1
lib/api/v3/triggers.rb
lib/api/v3/triggers.rb
+1
-1
spec/requests/api/triggers_spec.rb
spec/requests/api/triggers_spec.rb
+22
-8
spec/requests/api/v3/triggers_spec.rb
spec/requests/api/v3/triggers_spec.rb
+21
-7
No files found.
changelogs/unreleased/29438-fix-trigger-webhook-for-ref-with-dot.yml
0 → 100644
View file @
de518e12
---
title
:
Fix trigger webhook for ref with a dot
merge_request
:
10001
author
:
George Andrinopoulos
lib/api/triggers.rb
View file @
de518e12
...
@@ -14,7 +14,7 @@ module API
...
@@ -14,7 +14,7 @@ module API
requires
:token
,
type:
String
,
desc:
'The unique token of trigger'
requires
:token
,
type:
String
,
desc:
'The unique token of trigger'
optional
:variables
,
type:
Hash
,
desc:
'The list of variables to be injected into build'
optional
:variables
,
type:
Hash
,
desc:
'The list of variables to be injected into build'
end
end
post
":id/(ref/:ref/)trigger/pipeline"
do
post
":id/(ref/:ref/)trigger/pipeline"
,
requirements:
{
ref:
/.+/
}
do
project
=
find_project
(
params
[
:id
])
project
=
find_project
(
params
[
:id
])
trigger
=
Ci
::
Trigger
.
find_by_token
(
params
[
:token
].
to_s
)
trigger
=
Ci
::
Trigger
.
find_by_token
(
params
[
:token
].
to_s
)
not_found!
unless
project
&&
trigger
not_found!
unless
project
&&
trigger
...
...
lib/api/v3/triggers.rb
View file @
de518e12
...
@@ -15,7 +15,7 @@ module API
...
@@ -15,7 +15,7 @@ module API
requires
:token
,
type:
String
,
desc:
'The unique token of trigger'
requires
:token
,
type:
String
,
desc:
'The unique token of trigger'
optional
:variables
,
type:
Hash
,
desc:
'The list of variables to be injected into build'
optional
:variables
,
type:
Hash
,
desc:
'The list of variables to be injected into build'
end
end
post
":id/(ref/:ref/)trigger/builds"
do
post
":id/(ref/:ref/)trigger/builds"
,
requirements:
{
ref:
/.+/
}
do
project
=
find_project
(
params
[
:id
])
project
=
find_project
(
params
[
:id
])
trigger
=
Ci
::
Trigger
.
find_by_token
(
params
[
:token
].
to_s
)
trigger
=
Ci
::
Trigger
.
find_by_token
(
params
[
:token
].
to_s
)
not_found!
unless
project
&&
trigger
not_found!
unless
project
&&
trigger
...
...
spec/requests/api/triggers_spec.rb
View file @
de518e12
...
@@ -59,14 +59,6 @@ describe API::Triggers do
...
@@ -59,14 +59,6 @@ describe API::Triggers do
expect
(
pipeline
.
builds
.
size
).
to
eq
(
5
)
expect
(
pipeline
.
builds
.
size
).
to
eq
(
5
)
end
end
it
'creates builds on webhook from other gitlab repository and branch'
do
expect
do
post
api
(
"/projects/
#{
project
.
id
}
/ref/master/trigger/pipeline?token=
#{
trigger_token
}
"
),
{
ref:
'refs/heads/other-branch'
}
end
.
to
change
(
project
.
builds
,
:count
).
by
(
5
)
expect
(
response
).
to
have_http_status
(
201
)
end
it
'returns bad request with no pipeline created if there\'s no commit for that ref'
do
it
'returns bad request with no pipeline created if there\'s no commit for that ref'
do
post
api
(
"/projects/
#{
project
.
id
}
/trigger/pipeline"
),
options
.
merge
(
ref:
'other-branch'
)
post
api
(
"/projects/
#{
project
.
id
}
/trigger/pipeline"
),
options
.
merge
(
ref:
'other-branch'
)
...
@@ -101,6 +93,28 @@ describe API::Triggers do
...
@@ -101,6 +93,28 @@ describe API::Triggers do
end
end
end
end
end
end
context
'when triggering a pipeline from a trigger token'
do
it
'creates builds from the ref given in the URL, not in the body'
do
expect
do
post
api
(
"/projects/
#{
project
.
id
}
/ref/master/trigger/pipeline?token=
#{
trigger_token
}
"
),
{
ref:
'refs/heads/other-branch'
}
end
.
to
change
(
project
.
builds
,
:count
).
by
(
5
)
expect
(
response
).
to
have_http_status
(
201
)
end
context
'when ref contains a dot'
do
it
'creates builds from the ref given in the URL, not in the body'
do
project
.
repository
.
create_file
(
user
,
'.gitlab/gitlabhq/new_feature.md'
,
'something valid'
,
message:
'new_feature'
,
branch_name:
'v.1-branch'
)
expect
do
post
api
(
"/projects/
#{
project
.
id
}
/ref/v.1-branch/trigger/pipeline?token=
#{
trigger_token
}
"
),
{
ref:
'refs/heads/other-branch'
}
end
.
to
change
(
project
.
builds
,
:count
).
by
(
4
)
expect
(
response
).
to
have_http_status
(
201
)
end
end
end
end
end
describe
'GET /projects/:id/triggers'
do
describe
'GET /projects/:id/triggers'
do
...
...
spec/requests/api/v3/triggers_spec.rb
View file @
de518e12
...
@@ -51,13 +51,6 @@ describe API::V3::Triggers do
...
@@ -51,13 +51,6 @@ describe API::V3::Triggers do
expect
(
pipeline
.
builds
.
size
).
to
eq
(
5
)
expect
(
pipeline
.
builds
.
size
).
to
eq
(
5
)
end
end
it
'creates builds on webhook from other gitlab repository and branch'
do
expect
do
post
v3_api
(
"/projects/
#{
project
.
id
}
/ref/master/trigger/builds?token=
#{
trigger_token
}
"
),
{
ref:
'refs/heads/other-branch'
}
end
.
to
change
(
project
.
builds
,
:count
).
by
(
5
)
expect
(
response
).
to
have_http_status
(
201
)
end
it
'returns bad request with no builds created if there\'s no commit for that ref'
do
it
'returns bad request with no builds created if there\'s no commit for that ref'
do
post
v3_api
(
"/projects/
#{
project
.
id
}
/trigger/builds"
),
options
.
merge
(
ref:
'other-branch'
)
post
v3_api
(
"/projects/
#{
project
.
id
}
/trigger/builds"
),
options
.
merge
(
ref:
'other-branch'
)
expect
(
response
).
to
have_http_status
(
400
)
expect
(
response
).
to
have_http_status
(
400
)
...
@@ -89,6 +82,27 @@ describe API::V3::Triggers do
...
@@ -89,6 +82,27 @@ describe API::V3::Triggers do
end
end
end
end
end
end
context
'when triggering a pipeline from a trigger token'
do
it
'creates builds from the ref given in the URL, not in the body'
do
expect
do
post
v3_api
(
"/projects/
#{
project
.
id
}
/ref/master/trigger/builds?token=
#{
trigger_token
}
"
),
{
ref:
'refs/heads/other-branch'
}
end
.
to
change
(
project
.
builds
,
:count
).
by
(
5
)
expect
(
response
).
to
have_http_status
(
201
)
end
context
'when ref contains a dot'
do
it
'creates builds from the ref given in the URL, not in the body'
do
project
.
repository
.
create_file
(
user
,
'.gitlab/gitlabhq/new_feature.md'
,
'something valid'
,
message:
'new_feature'
,
branch_name:
'v.1-branch'
)
expect
do
post
v3_api
(
"/projects/
#{
project
.
id
}
/ref/v.1-branch/trigger/builds?token=
#{
trigger_token
}
"
),
{
ref:
'refs/heads/other-branch'
}
end
.
to
change
(
project
.
builds
,
:count
).
by
(
4
)
expect
(
response
).
to
have_http_status
(
201
)
end
end
end
end
end
describe
'GET /projects/:id/triggers'
do
describe
'GET /projects/:id/triggers'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment