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
Léo-Paul Géneau
gitlab-ce
Commits
47d6f286
Commit
47d6f286
authored
Aug 16, 2016
by
Z.J. van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add deployment endpoints
parent
fffe5c2b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
114 additions
and
1 deletion
+114
-1
CHANGELOG
CHANGELOG
+2
-1
lib/api/api.rb
lib/api/api.rb
+1
-0
lib/api/deployments.rb
lib/api/deployments.rb
+40
-0
lib/api/entities.rb
lib/api/entities.rb
+12
-0
spec/requests/api/deployments_spec.rb
spec/requests/api/deployments_spec.rb
+59
-0
No files found.
CHANGELOG
View file @
47d6f286
...
...
@@ -30,7 +30,8 @@ v 8.11.0 (unreleased)
- Expand commit message width in repo view (ClemMakesApps)
- Cache highlighted diff lines for merge requests
- Pre-create all builds for a Pipeline when the new Pipeline is created !5295
- Add Play endpoint on Builds
- API: Add deployment endpoints
- API: Add Play endpoint on Builds
- Fix of 'Commits being passed to custom hooks are already reachable when using the UI'
- Show member roles to all users on members page
- Project.visible_to_user is instrumented again
...
...
lib/api/api.rb
View file @
47d6f286
...
...
@@ -43,6 +43,7 @@ module API
mount
::
API
::
CommitStatuses
mount
::
API
::
Commits
mount
::
API
::
DeployKeys
mount
::
API
::
Deployments
mount
::
API
::
Environments
mount
::
API
::
Files
mount
::
API
::
Groups
...
...
lib/api/deployments.rb
0 → 100644
View file @
47d6f286
module
API
# Deployments RESTfull API endpoints
class
Deployments
<
Grape
::
API
before
{
authenticate!
}
params
do
requires
:id
,
type:
String
,
desc:
'The project ID'
end
resource
:projects
do
desc
'Get all deployments of the project'
do
detail
'This feature was introduced in GitLab 8.11.'
success
Entities
::
Deployment
end
params
do
optional
:page
,
type:
Integer
,
desc:
'Page number of the current request'
optional
:per_page
,
type:
Integer
,
desc:
'Number of items per page'
end
get
':id/deployments'
do
authorize!
:read_deployment
,
user_project
present
paginate
(
user_project
.
deployments
),
with:
Entities
::
Deployment
end
desc
'Gets a specific deployment'
do
detail
'This feature was introduced in GitLab 8.11.'
success
Entities
::
Deployment
end
params
do
requires
:deployment_id
,
type:
Integer
,
desc:
'The deployment ID'
end
get
':id/deployments/:deployment_id'
do
authorize!
:read_deployment
,
user_project
deployment
=
user_project
.
deployments
.
find
(
params
[
:deployment_id
])
present
deployment
,
with:
Entities
::
Deployment
end
end
end
end
lib/api/entities.rb
View file @
47d6f286
...
...
@@ -514,6 +514,18 @@ module API
expose
:id
,
:name
,
:external_url
end
class
EnvironmentBasic
<
Grape
::
Entity
expose
:id
,
:name
,
:external_url
end
class
Deployment
<
Grape
::
Entity
expose
:id
,
:iid
,
:ref
,
:sha
,
:created_at
expose
:project
,
using:
Entities
::
Project
expose
:user
,
using:
Entities
::
UserBasic
expose
:environment
,
using:
Entities
::
EnvironmentBasic
expose
:deployable
,
using:
Entities
::
Build
end
class
RepoLicense
<
Grape
::
Entity
expose
:key
,
:name
,
:nickname
expose
:featured
,
as: :popular
...
...
spec/requests/api/deployments_spec.rb
0 → 100644
View file @
47d6f286
require
'spec_helper'
describe
API
::
API
,
api:
true
do
include
ApiHelpers
let
(
:user
)
{
create
(
:user
)
}
let
(
:non_member
)
{
create
(
:user
)
}
let
(
:project
)
{
deployment
.
environment
.
project
}
let!
(
:deployment
)
{
create
(
:deployment
)
}
before
do
project
.
team
<<
[
user
,
:master
]
end
describe
'GET /projects/:id/deployments'
do
context
'as member of the project'
do
it_behaves_like
'a paginated resources'
do
let
(
:request
)
{
get
api
(
"/projects/
#{
project
.
id
}
/deployments"
,
user
)
}
end
it
'returns projects deployments'
do
get
api
(
"/projects/
#{
project
.
id
}
/deployments"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'iid'
]).
to
eq
(
deployment
.
iid
)
expect
(
json_response
.
first
[
'sha'
]).
to
match
/\A\h{40}\z/
end
end
context
'as non member'
do
it
'returns a 404 status code'
do
get
api
(
"/projects/
#{
project
.
id
}
/deployments"
,
non_member
)
expect
(
response
).
to
have_http_status
(
404
)
end
end
end
describe
'GET /projects/:id/deployments/:deployment_id'
do
context
'as a member of the project'
do
it
'returns the projects deployment'
do
get
api
(
"/projects/
#{
project
.
id
}
/deployments/
#{
deployment
.
id
}
"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
[
'sha'
]).
to
match
/\A\h{40}\z/
end
end
context
'as non member'
do
it
'returns a 404 status code'
do
get
api
(
"/projects/
#{
project
.
id
}
/deployments/
#{
deployment
.
id
}
"
,
non_member
)
expect
(
response
).
to
have_http_status
(
404
)
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