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
Boxiang Sun
gitlab-ce
Commits
53219857
Commit
53219857
authored
May 05, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check ability to update build on the API resource
parent
3264e09c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
5 deletions
+14
-5
lib/api/jobs.rb
lib/api/jobs.rb
+7
-2
lib/api/v3/builds.rb
lib/api/v3/builds.rb
+7
-3
No files found.
lib/api/jobs.rb
View file @
53219857
...
@@ -132,6 +132,7 @@ module API
...
@@ -132,6 +132,7 @@ module API
authorize_update_builds!
authorize_update_builds!
build
=
get_build!
(
params
[
:job_id
])
build
=
get_build!
(
params
[
:job_id
])
authorize!
(
:update_build
,
build
)
build
.
cancel
build
.
cancel
...
@@ -148,6 +149,7 @@ module API
...
@@ -148,6 +149,7 @@ module API
authorize_update_builds!
authorize_update_builds!
build
=
get_build!
(
params
[
:job_id
])
build
=
get_build!
(
params
[
:job_id
])
authorize!
(
:update_build
,
build
)
return
forbidden!
(
'Job is not retryable'
)
unless
build
.
retryable?
return
forbidden!
(
'Job is not retryable'
)
unless
build
.
retryable?
build
=
Ci
::
Build
.
retry
(
build
,
current_user
)
build
=
Ci
::
Build
.
retry
(
build
,
current_user
)
...
@@ -165,6 +167,7 @@ module API
...
@@ -165,6 +167,7 @@ module API
authorize_update_builds!
authorize_update_builds!
build
=
get_build!
(
params
[
:job_id
])
build
=
get_build!
(
params
[
:job_id
])
authorize!
(
:update_build
,
build
)
return
forbidden!
(
'Job is not erasable!'
)
unless
build
.
erasable?
return
forbidden!
(
'Job is not erasable!'
)
unless
build
.
erasable?
build
.
erase
(
erased_by:
current_user
)
build
.
erase
(
erased_by:
current_user
)
...
@@ -181,6 +184,7 @@ module API
...
@@ -181,6 +184,7 @@ module API
authorize_update_builds!
authorize_update_builds!
build
=
get_build!
(
params
[
:job_id
])
build
=
get_build!
(
params
[
:job_id
])
authorize!
(
:update_build
,
build
)
return
not_found!
(
build
)
unless
build
.
artifacts?
return
not_found!
(
build
)
unless
build
.
artifacts?
build
.
keep_artifacts!
build
.
keep_artifacts!
...
@@ -201,6 +205,7 @@ module API
...
@@ -201,6 +205,7 @@ module API
build
=
get_build!
(
params
[
:job_id
])
build
=
get_build!
(
params
[
:job_id
])
authorize!
(
:update_build
,
build
)
bad_request!
(
"Unplayable Job"
)
unless
build
.
playable?
bad_request!
(
"Unplayable Job"
)
unless
build
.
playable?
build
.
play
(
current_user
)
build
.
play
(
current_user
)
...
@@ -211,12 +216,12 @@ module API
...
@@ -211,12 +216,12 @@ module API
end
end
helpers
do
helpers
do
def
get
_build
(
id
)
def
find
_build
(
id
)
user_project
.
builds
.
find_by
(
id:
id
.
to_i
)
user_project
.
builds
.
find_by
(
id:
id
.
to_i
)
end
end
def
get_build!
(
id
)
def
get_build!
(
id
)
get
_build
(
id
)
||
not_found!
find
_build
(
id
)
||
not_found!
end
end
def
present_artifacts!
(
artifacts_file
)
def
present_artifacts!
(
artifacts_file
)
...
...
lib/api/v3/builds.rb
View file @
53219857
...
@@ -134,6 +134,7 @@ module API
...
@@ -134,6 +134,7 @@ module API
authorize_update_builds!
authorize_update_builds!
build
=
get_build!
(
params
[
:build_id
])
build
=
get_build!
(
params
[
:build_id
])
authorize!
(
:update_build
,
build
)
build
.
cancel
build
.
cancel
...
@@ -150,6 +151,7 @@ module API
...
@@ -150,6 +151,7 @@ module API
authorize_update_builds!
authorize_update_builds!
build
=
get_build!
(
params
[
:build_id
])
build
=
get_build!
(
params
[
:build_id
])
authorize!
(
:update_build
,
build
)
return
forbidden!
(
'Build is not retryable'
)
unless
build
.
retryable?
return
forbidden!
(
'Build is not retryable'
)
unless
build
.
retryable?
build
=
Ci
::
Build
.
retry
(
build
,
current_user
)
build
=
Ci
::
Build
.
retry
(
build
,
current_user
)
...
@@ -167,6 +169,7 @@ module API
...
@@ -167,6 +169,7 @@ module API
authorize_update_builds!
authorize_update_builds!
build
=
get_build!
(
params
[
:build_id
])
build
=
get_build!
(
params
[
:build_id
])
authorize!
(
:update_build
,
build
)
return
forbidden!
(
'Build is not erasable!'
)
unless
build
.
erasable?
return
forbidden!
(
'Build is not erasable!'
)
unless
build
.
erasable?
build
.
erase
(
erased_by:
current_user
)
build
.
erase
(
erased_by:
current_user
)
...
@@ -183,6 +186,7 @@ module API
...
@@ -183,6 +186,7 @@ module API
authorize_update_builds!
authorize_update_builds!
build
=
get_build!
(
params
[
:build_id
])
build
=
get_build!
(
params
[
:build_id
])
authorize!
(
:update_build
,
build
)
return
not_found!
(
build
)
unless
build
.
artifacts?
return
not_found!
(
build
)
unless
build
.
artifacts?
build
.
keep_artifacts!
build
.
keep_artifacts!
...
@@ -202,7 +206,7 @@ module API
...
@@ -202,7 +206,7 @@ module API
authorize_read_builds!
authorize_read_builds!
build
=
get_build!
(
params
[
:build_id
])
build
=
get_build!
(
params
[
:build_id
])
authorize!
(
:update_build
,
build
)
bad_request!
(
"Unplayable Job"
)
unless
build
.
playable?
bad_request!
(
"Unplayable Job"
)
unless
build
.
playable?
build
.
play
(
current_user
)
build
.
play
(
current_user
)
...
@@ -213,12 +217,12 @@ module API
...
@@ -213,12 +217,12 @@ module API
end
end
helpers
do
helpers
do
def
get
_build
(
id
)
def
find
_build
(
id
)
user_project
.
builds
.
find_by
(
id:
id
.
to_i
)
user_project
.
builds
.
find_by
(
id:
id
.
to_i
)
end
end
def
get_build!
(
id
)
def
get_build!
(
id
)
get
_build
(
id
)
||
not_found!
find
_build
(
id
)
||
not_found!
end
end
def
present_artifacts!
(
artifacts_file
)
def
present_artifacts!
(
artifacts_file
)
...
...
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