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
38a1378e
Commit
38a1378e
authored
Mar 29, 2016
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add incremental build trace update API
parent
d7127890
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
1 deletion
+44
-1
app/models/ci/build.rb
app/models/ci/build.rb
+13
-1
lib/ci/api/builds.rb
lib/ci/api/builds.rb
+9
-0
spec/requests/ci/api/builds_spec.rb
spec/requests/ci/api/builds_spec.rb
+22
-0
No files found.
app/models/ci/build.rb
View file @
38a1378e
...
...
@@ -231,11 +231,23 @@ module Ci
end
def
trace
=
(
trace
)
recreate_trace_dir
File
.
write
(
path_to_trace
,
trace
)
end
def
recreate_trace_dir
unless
Dir
.
exists?
(
dir_to_trace
)
FileUtils
.
mkdir_p
(
dir_to_trace
)
end
end
private
:recreate_trace_dir
File
.
write
(
path_to_trace
,
trace
)
def
append_trace
(
trace_part
)
recreate_trace_dir
File
.
open
(
path_to_trace
,
'a'
)
do
|
f
|
f
.
write
(
trace_part
)
end
end
def
dir_to_trace
...
...
lib/ci/api/builds.rb
View file @
38a1378e
...
...
@@ -50,6 +50,15 @@ module Ci
end
end
patch
":id/trace.txt"
do
authenticate_runner!
update_runner_last_contact
build
=
Ci
::
Build
.
where
(
runner_id:
current_runner
.
id
).
running
.
find
(
params
[
:id
])
forbidden!
(
'Build has been erased!'
)
if
build
.
erased?
build
.
append_trace
(
params
[
:trace_part
])
end
# Authorize artifacts uploading for build - Runners only
#
# Parameters:
...
...
spec/requests/ci/api/builds_spec.rb
View file @
38a1378e
...
...
@@ -156,6 +156,28 @@ describe Ci::API::API do
end
end
describe
'PATCH /builds/:id/trace.txt'
do
let
(
:build
)
{
create
(
:ci_build
,
:trace
,
runner_id:
runner
.
id
)
}
before
do
build
.
run!
patch
ci_api
(
"/builds/
#{
build
.
id
}
/trace.txt"
),
trace_part:
' appended'
,
token:
runner
.
token
end
it
'should append trace part to the trace'
do
expect
(
response
.
status
).
to
eq
200
expect
(
build
.
reload
.
trace
).
to
eq
'BUILD TRACE appended'
end
context
'when build has been erased'
do
let
(
:build
)
{
create
(
:ci_build
,
runner_id:
runner
.
id
,
erased_at:
Time
.
now
)
}
it
'should respond with forbidden'
do
expect
(
response
.
status
).
to
eq
403
end
end
end
context
"Artifacts"
do
let
(
:file_upload
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/banana_sample.gif'
,
'image/gif'
)
}
let
(
:file_upload2
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/dk.png'
,
'image/gif'
)
}
...
...
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