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
Show 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
...
@@ -50,10 +50,14 @@ module API
forbidden!
(
'Job has been erased!'
)
if
job
.
erased?
forbidden!
(
'Job has been erased!'
)
if
job
.
erased?
end
end
def
authenticate_job!
(
job
)
def
authenticate_job!
job
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
validate_job!
(
job
)
do
validate_job!
(
job
)
do
forbidden!
unless
job_token_valid?
(
job
)
forbidden!
unless
job_token_valid?
(
job
)
end
end
job
end
end
def
job_token_valid?
(
job
)
def
job_token_valid?
(
job
)
...
...
lib/api/runner.rb
View file @
e431b4c4
...
@@ -113,8 +113,7 @@ module API
...
@@ -113,8 +113,7 @@ module API
optional
:state
,
type:
String
,
desc:
%q(Job's status: success, failed)
optional
:state
,
type:
String
,
desc:
%q(Job's status: success, failed)
end
end
put
'/:id'
do
put
'/:id'
do
job
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
job
=
authenticate_job!
authenticate_job!
(
job
)
job
.
update_attributes
(
trace:
params
[
:trace
])
if
params
[
:trace
]
job
.
update_attributes
(
trace:
params
[
:trace
])
if
params
[
:trace
]
...
@@ -140,8 +139,7 @@ module API
...
@@ -140,8 +139,7 @@ module API
optional
:token
,
type:
String
,
desc:
%q(Job's authentication token)
optional
:token
,
type:
String
,
desc:
%q(Job's authentication token)
end
end
patch
'/:id/trace'
do
patch
'/:id/trace'
do
job
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
job
=
authenticate_job!
authenticate_job!
(
job
)
error!
(
'400 Missing header Content-Range'
,
400
)
unless
request
.
headers
.
has_key?
(
'Content-Range'
)
error!
(
'400 Missing header Content-Range'
,
400
)
unless
request
.
headers
.
has_key?
(
'Content-Range'
)
content_range
=
request
.
headers
[
'Content-Range'
]
content_range
=
request
.
headers
[
'Content-Range'
]
...
@@ -175,8 +173,7 @@ module API
...
@@ -175,8 +173,7 @@ module API
require_gitlab_workhorse!
require_gitlab_workhorse!
Gitlab
::
Workhorse
.
verify_api_request!
(
headers
)
Gitlab
::
Workhorse
.
verify_api_request!
(
headers
)
job
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
job
=
authenticate_job!
authenticate_job!
(
job
)
forbidden!
(
'Job is not running'
)
unless
job
.
running?
forbidden!
(
'Job is not running'
)
unless
job
.
running?
if
params
[
:filesize
]
if
params
[
:filesize
]
...
@@ -212,8 +209,7 @@ module API
...
@@ -212,8 +209,7 @@ module API
not_allowed!
unless
Gitlab
.
config
.
artifacts
.
enabled
not_allowed!
unless
Gitlab
.
config
.
artifacts
.
enabled
require_gitlab_workhorse!
require_gitlab_workhorse!
job
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
job
=
authenticate_job!
authenticate_job!
(
job
)
forbidden!
(
'Job is not running!'
)
unless
job
.
running?
forbidden!
(
'Job is not running!'
)
unless
job
.
running?
artifacts_upload_path
=
ArtifactUploader
.
artifacts_upload_path
artifacts_upload_path
=
ArtifactUploader
.
artifacts_upload_path
...
@@ -245,8 +241,7 @@ module API
...
@@ -245,8 +241,7 @@ module API
optional
:token
,
type:
String
,
desc:
%q(Job's authentication token)
optional
:token
,
type:
String
,
desc:
%q(Job's authentication token)
end
end
get
'/:id/artifacts'
do
get
'/:id/artifacts'
do
job
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
job
=
authenticate_job!
authenticate_job!
(
job
)
artifacts_file
=
job
.
artifacts_file
artifacts_file
=
job
.
artifacts_file
unless
artifacts_file
.
file_storage?
unless
artifacts_file
.
file_storage?
...
...
lib/ci/api/builds.rb
View file @
e431b4c4
...
@@ -86,8 +86,7 @@ module Ci
...
@@ -86,8 +86,7 @@ module Ci
# Example Request:
# Example Request:
# PATCH /builds/:id/trace.txt
# PATCH /builds/:id/trace.txt
patch
":id/trace.txt"
do
patch
":id/trace.txt"
do
build
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
build
=
authenticate_build!
authenticate_build!
(
build
)
error!
(
'400 Missing header Content-Range'
,
400
)
unless
request
.
headers
.
has_key?
(
'Content-Range'
)
error!
(
'400 Missing header Content-Range'
,
400
)
unless
request
.
headers
.
has_key?
(
'Content-Range'
)
content_range
=
request
.
headers
[
'Content-Range'
]
content_range
=
request
.
headers
[
'Content-Range'
]
...
@@ -117,8 +116,7 @@ module Ci
...
@@ -117,8 +116,7 @@ module Ci
require_gitlab_workhorse!
require_gitlab_workhorse!
Gitlab
::
Workhorse
.
verify_api_request!
(
headers
)
Gitlab
::
Workhorse
.
verify_api_request!
(
headers
)
not_allowed!
unless
Gitlab
.
config
.
artifacts
.
enabled
not_allowed!
unless
Gitlab
.
config
.
artifacts
.
enabled
build
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
build
=
authenticate_build!
authenticate_build!
(
build
)
forbidden!
(
'build is not running'
)
unless
build
.
running?
forbidden!
(
'build is not running'
)
unless
build
.
running?
if
params
[
:filesize
]
if
params
[
:filesize
]
...
@@ -154,8 +152,7 @@ module Ci
...
@@ -154,8 +152,7 @@ module Ci
post
":id/artifacts"
do
post
":id/artifacts"
do
require_gitlab_workhorse!
require_gitlab_workhorse!
not_allowed!
unless
Gitlab
.
config
.
artifacts
.
enabled
not_allowed!
unless
Gitlab
.
config
.
artifacts
.
enabled
build
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
build
=
authenticate_build!
authenticate_build!
(
build
)
forbidden!
(
'Build is not running!'
)
unless
build
.
running?
forbidden!
(
'Build is not running!'
)
unless
build
.
running?
artifacts_upload_path
=
ArtifactUploader
.
artifacts_upload_path
artifacts_upload_path
=
ArtifactUploader
.
artifacts_upload_path
...
@@ -189,8 +186,7 @@ module Ci
...
@@ -189,8 +186,7 @@ module Ci
# Example Request:
# Example Request:
# GET /builds/:id/artifacts
# GET /builds/:id/artifacts
get
":id/artifacts"
do
get
":id/artifacts"
do
build
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
build
=
authenticate_build!
authenticate_build!
(
build
)
artifacts_file
=
build
.
artifacts_file
artifacts_file
=
build
.
artifacts_file
unless
artifacts_file
.
file_storage?
unless
artifacts_file
.
file_storage?
...
@@ -214,8 +210,7 @@ module Ci
...
@@ -214,8 +210,7 @@ module Ci
# Example Request:
# Example Request:
# DELETE /builds/:id/artifacts
# DELETE /builds/:id/artifacts
delete
":id/artifacts"
do
delete
":id/artifacts"
do
build
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
build
=
authenticate_build!
authenticate_build!
(
build
)
status
(
200
)
status
(
200
)
build
.
erase_artifacts!
build
.
erase_artifacts!
...
...
lib/ci/api/helpers.rb
View file @
e431b4c4
...
@@ -13,10 +13,14 @@ module Ci
...
@@ -13,10 +13,14 @@ module Ci
forbidden!
unless
current_runner
forbidden!
unless
current_runner
end
end
def
authenticate_build!
(
build
)
def
authenticate_build!
build
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
validate_build!
(
build
)
do
validate_build!
(
build
)
do
forbidden!
unless
build_token_valid?
(
build
)
forbidden!
unless
build_token_valid?
(
build
)
end
end
build
end
end
def
validate_build!
(
build
)
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