BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
e431b4c4
Commit
e431b4c4
authored
Apr 04, 2017
by
Kamil Trzciński
Committed by
James Lopez
Apr 04, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge branch 'backport-sticking-api-helper-changes' into 'master'
Backport API changes needed to fix sticking in EE See merge request !10376
parent
956ed72e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
22 deletions
+24
-22
backport-sticking-api-helper-changes.yml
...elogs/unreleased/backport-sticking-api-helper-changes.yml
+4
-0
runner.rb
lib/api/helpers/runner.rb
+5
-1
runner.rb
lib/api/runner.rb
+5
-10
builds.rb
lib/ci/api/builds.rb
+5
-10
helpers.rb
lib/ci/api/helpers.rb
+5
-1
No files found.
changelogs/unreleased/backport-sticking-api-helper-changes.yml
0 → 100644
View file @
e431b4c4
---
title
:
Backport API changes needed to fix sticking in EE
merge_request
:
author
:
lib/api/helpers/runner.rb
View file @
e431b4c4
...
...
@@ -50,10 +50,14 @@ module API
forbidden!
(
'Job has been erased!'
)
if
job
.
erased?
end
def
authenticate_job!
(
job
)
def
authenticate_job!
job
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
validate_job!
(
job
)
do
forbidden!
unless
job_token_valid?
(
job
)
end
job
end
def
job_token_valid?
(
job
)
...
...
lib/api/runner.rb
View file @
e431b4c4
...
...
@@ -113,8 +113,7 @@ module API
optional
:state
,
type:
String
,
desc:
%q(Job's status: success, failed)
end
put
'/:id'
do
job
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
authenticate_job!
(
job
)
job
=
authenticate_job!
job
.
update_attributes
(
trace:
params
[
:trace
])
if
params
[
:trace
]
...
...
@@ -140,8 +139,7 @@ module API
optional
:token
,
type:
String
,
desc:
%q(Job's authentication token)
end
patch
'/:id/trace'
do
job
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
authenticate_job!
(
job
)
job
=
authenticate_job!
error!
(
'400 Missing header Content-Range'
,
400
)
unless
request
.
headers
.
has_key?
(
'Content-Range'
)
content_range
=
request
.
headers
[
'Content-Range'
]
...
...
@@ -175,8 +173,7 @@ module API
require_gitlab_workhorse!
Gitlab
::
Workhorse
.
verify_api_request!
(
headers
)
job
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
authenticate_job!
(
job
)
job
=
authenticate_job!
forbidden!
(
'Job is not running'
)
unless
job
.
running?
if
params
[
:filesize
]
...
...
@@ -212,8 +209,7 @@ module API
not_allowed!
unless
Gitlab
.
config
.
artifacts
.
enabled
require_gitlab_workhorse!
job
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
authenticate_job!
(
job
)
job
=
authenticate_job!
forbidden!
(
'Job is not running!'
)
unless
job
.
running?
artifacts_upload_path
=
ArtifactUploader
.
artifacts_upload_path
...
...
@@ -245,8 +241,7 @@ module API
optional
:token
,
type:
String
,
desc:
%q(Job's authentication token)
end
get
'/:id/artifacts'
do
job
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
authenticate_job!
(
job
)
job
=
authenticate_job!
artifacts_file
=
job
.
artifacts_file
unless
artifacts_file
.
file_storage?
...
...
lib/ci/api/builds.rb
View file @
e431b4c4
...
...
@@ -86,8 +86,7 @@ module Ci
# Example Request:
# PATCH /builds/:id/trace.txt
patch
":id/trace.txt"
do
build
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
authenticate_build!
(
build
)
build
=
authenticate_build!
error!
(
'400 Missing header Content-Range'
,
400
)
unless
request
.
headers
.
has_key?
(
'Content-Range'
)
content_range
=
request
.
headers
[
'Content-Range'
]
...
...
@@ -117,8 +116,7 @@ module Ci
require_gitlab_workhorse!
Gitlab
::
Workhorse
.
verify_api_request!
(
headers
)
not_allowed!
unless
Gitlab
.
config
.
artifacts
.
enabled
build
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
authenticate_build!
(
build
)
build
=
authenticate_build!
forbidden!
(
'build is not running'
)
unless
build
.
running?
if
params
[
:filesize
]
...
...
@@ -154,8 +152,7 @@ module Ci
post
":id/artifacts"
do
require_gitlab_workhorse!
not_allowed!
unless
Gitlab
.
config
.
artifacts
.
enabled
build
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
authenticate_build!
(
build
)
build
=
authenticate_build!
forbidden!
(
'Build is not running!'
)
unless
build
.
running?
artifacts_upload_path
=
ArtifactUploader
.
artifacts_upload_path
...
...
@@ -189,8 +186,7 @@ module Ci
# Example Request:
# GET /builds/:id/artifacts
get
":id/artifacts"
do
build
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
authenticate_build!
(
build
)
build
=
authenticate_build!
artifacts_file
=
build
.
artifacts_file
unless
artifacts_file
.
file_storage?
...
...
@@ -214,8 +210,7 @@ module Ci
# Example Request:
# DELETE /builds/:id/artifacts
delete
":id/artifacts"
do
build
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
authenticate_build!
(
build
)
build
=
authenticate_build!
status
(
200
)
build
.
erase_artifacts!
...
...
lib/ci/api/helpers.rb
View file @
e431b4c4
...
...
@@ -13,10 +13,14 @@ module Ci
forbidden!
unless
current_runner
end
def
authenticate_build!
(
build
)
def
authenticate_build!
build
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
validate_build!
(
build
)
do
forbidden!
unless
build_token_valid?
(
build
)
end
build
end
def
validate_build!
(
build
)
...
...
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