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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
6ca9339d
Commit
6ca9339d
authored
Apr 29, 2018
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master' into ce-to-ee-2018-04-29
parents
0b429028
87f1736a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
0 deletions
+36
-0
app/finders/pipelines_finder.rb
app/finders/pipelines_finder.rb
+9
-0
changelogs/unreleased/jramsay-44880-filter-pipelines-by-sha.yml
...logs/unreleased/jramsay-44880-filter-pipelines-by-sha.yml
+5
-0
doc/api/pipelines.md
doc/api/pipelines.md
+1
-0
lib/api/pipelines.rb
lib/api/pipelines.rb
+1
-0
spec/finders/pipelines_finder_spec.rb
spec/finders/pipelines_finder_spec.rb
+20
-0
No files found.
app/finders/pipelines_finder.rb
View file @
6ca9339d
...
...
@@ -14,6 +14,7 @@ class PipelinesFinder
items
=
by_scope
(
items
)
items
=
by_status
(
items
)
items
=
by_ref
(
items
)
items
=
by_sha
(
items
)
items
=
by_name
(
items
)
items
=
by_username
(
items
)
items
=
by_yaml_errors
(
items
)
...
...
@@ -69,6 +70,14 @@ class PipelinesFinder
end
end
def
by_sha
(
items
)
if
params
[
:sha
].
present?
items
.
where
(
sha:
params
[
:sha
])
else
items
end
end
def
by_name
(
items
)
if
params
[
:name
].
present?
items
.
joins
(
:user
).
where
(
users:
{
name:
params
[
:name
]
})
...
...
changelogs/unreleased/jramsay-44880-filter-pipelines-by-sha.yml
0 → 100644
View file @
6ca9339d
---
title
:
Add sha filter to pipelines list API
merge_request
:
18125
author
:
type
:
changed
doc/api/pipelines.md
View file @
6ca9339d
...
...
@@ -14,6 +14,7 @@ GET /projects/:id/pipelines
|
`scope`
| string | no | The scope of pipelines, one of:
`running`
,
`pending`
,
`finished`
,
`branches`
,
`tags`
|
|
`status`
| string | no | The status of pipelines, one of:
`running`
,
`pending`
,
`success`
,
`failed`
,
`canceled`
,
`skipped`
|
|
`ref`
| string | no | The ref of pipelines |
|
`sha`
| string | no | The sha or pipelines |
|
`yaml_errors`
| boolean | no | Returns pipelines with invalid configurations |
|
`name`
| string | no | The name of the user who triggered pipelines |
|
`username`
| string | no | The username of the user who triggered pipelines |
...
...
lib/api/pipelines.rb
View file @
6ca9339d
...
...
@@ -19,6 +19,7 @@ module API
optional
:status
,
type:
String
,
values:
HasStatus
::
AVAILABLE_STATUSES
,
desc:
'The status of pipelines'
optional
:ref
,
type:
String
,
desc:
'The ref of pipelines'
optional
:sha
,
type:
String
,
desc:
'The sha of pipelines'
optional
:yaml_errors
,
type:
Boolean
,
desc:
'Returns pipelines with invalid configurations'
optional
:name
,
type:
String
,
desc:
'The name of the user who triggered pipelines'
optional
:username
,
type:
String
,
desc:
'The username of the user who triggered pipelines'
...
...
spec/finders/pipelines_finder_spec.rb
View file @
6ca9339d
...
...
@@ -203,5 +203,25 @@ describe PipelinesFinder do
end
end
end
context
'when sha is specified'
do
let!
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
,
sha:
'97de212e80737a608d939f648d959671fb0a0142'
)
}
context
'when sha exists'
do
let
(
:params
)
{
{
sha:
'97de212e80737a608d939f648d959671fb0a0142'
}
}
it
'returns matched pipelines'
do
is_expected
.
to
eq
([
pipeline
])
end
end
context
'when sha does not exist'
do
let
(
:params
)
{
{
sha:
'invalid-sha'
}
}
it
'returns empty'
do
is_expected
.
to
be_empty
end
end
end
end
end
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