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
63a9d582
Commit
63a9d582
authored
Jan 25, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Trace as artifacts
parent
84bda43a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
10 deletions
+33
-10
app/models/ci/build.rb
app/models/ci/build.rb
+1
-0
app/models/ci/job_artifact.rb
app/models/ci/job_artifact.rb
+4
-1
app/uploaders/job_artifact_uploader.rb
app/uploaders/job_artifact_uploader.rb
+4
-0
lib/api/runner.rb
lib/api/runner.rb
+10
-1
lib/gitlab/ci/trace.rb
lib/gitlab/ci/trace.rb
+14
-8
No files found.
app/models/ci/build.rb
View file @
63a9d582
...
...
@@ -21,6 +21,7 @@ module Ci
has_many
:job_artifacts
,
class_name:
'Ci::JobArtifact'
,
foreign_key: :job_id
,
dependent: :destroy
# rubocop:disable Cop/ActiveRecordDependent
has_one
:job_artifacts_archive
,
->
{
where
(
file_type:
Ci
::
JobArtifact
.
file_types
[
:archive
])
},
class_name:
'Ci::JobArtifact'
,
inverse_of: :job
,
foreign_key: :job_id
has_one
:job_artifacts_metadata
,
->
{
where
(
file_type:
Ci
::
JobArtifact
.
file_types
[
:metadata
])
},
class_name:
'Ci::JobArtifact'
,
inverse_of: :job
,
foreign_key: :job_id
has_one
:job_artifacts_trace
,
->
{
where
(
file_type:
Ci
::
JobArtifact
.
file_types
[
:trace
])
},
class_name:
'Ci::JobArtifact'
,
inverse_of: :job
,
foreign_key: :job_id
# The "environment" field for builds is a String, and is the unexpanded name
def
persisted_environment
...
...
app/models/ci/job_artifact.rb
View file @
63a9d582
...
...
@@ -9,9 +9,12 @@ module Ci
mount_uploader
:file
,
JobArtifactUploader
delegate
:open
,
:exists?
,
to: :file
enum
file_type:
{
archive:
1
,
metadata:
2
metadata:
2
,
trace:
3
}
def
self
.
artifacts_size_for
(
project
)
...
...
app/uploaders/job_artifact_uploader.rb
View file @
63a9d582
...
...
@@ -13,6 +13,10 @@ class JobArtifactUploader < GitlabUploader
dynamic_segment
end
def
open
File
.
open
(
path
,
"rb"
)
end
private
def
dynamic_segment
...
...
lib/api/runner.rb
View file @
63a9d582
...
...
@@ -120,7 +120,16 @@ module API
put
'/:id'
do
job
=
authenticate_job!
job
.
trace
.
set
(
params
[
:trace
])
if
params
[
:trace
]
if
params
[
:trace
]
# Overwrite live-trace by full-trace
job
.
trace
.
set
(
params
[
:trace
])
# Move full-trace to JobArtifactUploader#default_path
job
.
build_job_artifacts_trace
(
project:
job
.
project
,
file_type: :trace
,
file:
UploadedFile
.
new
(
job
.
trace
.
current_path
,
'trace.log'
))
end
Gitlab
::
Metrics
.
add_event
(
:update_build
,
project:
job
.
project
.
full_path
)
...
...
lib/gitlab/ci/trace.rb
View file @
63a9d582
...
...
@@ -52,12 +52,14 @@ module Gitlab
end
def
exist?
current_path
.
present?
||
old_trace
.
present?
trace_artifact
&
.
exists?
||
current_path
.
present?
||
old_trace
.
present?
end
def
read
stream
=
Gitlab
::
Ci
::
Trace
::
Stream
.
new
do
if
current_path
if
trace_artifact
trace_artifact
.
open
elsif
current_path
File
.
open
(
current_path
,
"rb"
)
elsif
old_trace
StringIO
.
new
(
old_trace
)
...
...
@@ -104,12 +106,6 @@ module Gitlab
end
end
def
current_path
@current_path
||=
paths
.
find
do
|
trace_path
|
File
.
exist?
(
trace_path
)
end
end
def
paths
[
default_path
,
...
...
@@ -117,6 +113,12 @@ module Gitlab
].
compact
end
def
current_path
@current_path
||=
paths
.
find
do
|
trace_path
|
File
.
exist?
(
trace_path
)
end
end
def
default_directory
File
.
join
(
Settings
.
gitlab_ci
.
builds_path
,
...
...
@@ -137,6 +139,10 @@ module Gitlab
"
#{
job
.
id
}
.log"
)
if
job
.
project
&
.
ci_id
end
def
trace_artifact
job
.
job_artifacts_trace
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