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
da9d42f2
Commit
da9d42f2
authored
Oct 03, 2017
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '37970-timestamped-ci' into 'master'
Hide CI section markers from job trace See merge request gitlab-org/gitlab-ce!14393
parents
c3462235
79e1f33f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
1 deletion
+51
-1
build.rb
app/models/ci/build.rb
+4
-0
37970-timestamped-ci.yml
changelogs/unreleased/37970-timestamped-ci.yml
+5
-0
entities.rb
lib/api/entities.rb
+1
-0
ansi2html.rb
lib/gitlab/ci/ansi2html.rb
+12
-1
ansi2html_spec.rb
spec/lib/gitlab/ci/ansi2html_spec.rb
+26
-0
runner_spec.rb
spec/requests/api/runner_spec.rb
+3
-0
No files found.
app/models/ci/build.rb
View file @
da9d42f2
...
...
@@ -229,6 +229,10 @@ module Ci
variables
end
def
features
{
trace_sections:
true
}
end
def
merge_request
return
@merge_request
if
defined?
(
@merge_request
)
...
...
changelogs/unreleased/37970-timestamped-ci.yml
0 → 100644
View file @
da9d42f2
---
title
:
Strip gitlab-runner section markers in build trace HTML view
merge_request
:
14393
author
:
type
:
added
lib/api/entities.rb
View file @
da9d42f2
...
...
@@ -1022,6 +1022,7 @@ module API
expose
:cache
,
using:
Cache
expose
:credentials
,
using:
Credentials
expose
:dependencies
,
using:
Dependency
expose
:features
end
end
...
...
lib/gitlab/ci/ansi2html.rb
View file @
da9d42f2
...
...
@@ -155,7 +155,9 @@ module Gitlab
stream
.
each_line
do
|
line
|
s
=
StringScanner
.
new
(
line
)
until
s
.
eos?
if
s
.
scan
(
/\e([@-_])(.*?)([@-~])/
)
if
s
.
scan
(
/section_((?:start)|(?:end)):(\d+):([^\r]+)\r\033\[0K/
)
handle_section
(
s
)
elsif
s
.
scan
(
/\e([@-_])(.*?)([@-~])/
)
handle_sequence
(
s
)
elsif
s
.
scan
(
/\e(([@-_])(.*?)?)?$/
)
break
...
...
@@ -183,6 +185,15 @@ module Gitlab
)
end
def
handle_section
(
s
)
action
=
s
[
1
]
timestamp
=
s
[
2
]
section
=
s
[
3
]
line
=
s
.
matched
()[
0
...-
5
]
# strips \r\033[0K
@out
<<
%{<div class="hidden" data-action="#{action}" data-timestamp="#{timestamp}" data-section="#{section}">#{line}</div>}
end
def
handle_sequence
(
s
)
indicator
=
s
[
1
]
commands
=
s
[
2
].
split
';'
...
...
spec/lib/gitlab/ci/ansi2html_spec.rb
View file @
da9d42f2
...
...
@@ -195,6 +195,32 @@ describe Gitlab::Ci::Ansi2html do
end
end
context
"with section markers"
do
let
(
:section_name
)
{
'test_section'
}
let
(
:section_start_time
)
{
Time
.
new
(
2017
,
9
,
20
).
utc
}
let
(
:section_duration
)
{
3
.
seconds
}
let
(
:section_end_time
)
{
section_start_time
+
section_duration
}
let
(
:section_start
)
{
"section_start:
#{
section_start_time
.
to_i
}
:
#{
section_name
}
\r\033
[0K"
}
let
(
:section_end
)
{
"section_end:
#{
section_end_time
.
to_i
}
:
#{
section_name
}
\r\033
[0K"
}
let
(
:section_start_html
)
do
'<div class="hidden" data-action="start"'
\
" data-timestamp=
\"
#{
section_start_time
.
to_i
}
\"
data-section=
\"
#{
section_name
}
\"
>"
\
"
#{
section_start
[
0
...-
5
]
}
</div>"
end
let
(
:section_end_html
)
do
'<div class="hidden" data-action="end"'
\
" data-timestamp=
\"
#{
section_end_time
.
to_i
}
\"
data-section=
\"
#{
section_name
}
\"
>"
\
"
#{
section_end
[
0
...-
5
]
}
</div>"
end
it
"prints light red"
do
text
=
"
#{
section_start
}
\e
[91mHello
\e
[0m
\n
#{
section_end
}
"
html
=
%{#{section_start_html}<span class="term-fg-l-red">Hello</span><br>#{section_end_html}}
expect
(
convert_html
(
text
)).
to
eq
(
html
)
end
end
describe
"truncates"
do
let
(
:text
)
{
"Hello World"
}
let
(
:stream
)
{
StringIO
.
new
(
text
)
}
...
...
spec/requests/api/runner_spec.rb
View file @
da9d42f2
...
...
@@ -360,6 +360,8 @@ describe API::Runner do
'policy'
=>
'pull-push'
}]
end
let
(
:expected_features
)
{
{
'trace_sections'
=>
true
}
}
it
'picks a job'
do
request_job
info:
{
platform: :darwin
}
...
...
@@ -379,6 +381,7 @@ describe API::Runner do
expect
(
json_response
[
'artifacts'
]).
to
eq
(
expected_artifacts
)
expect
(
json_response
[
'cache'
]).
to
eq
(
expected_cache
)
expect
(
json_response
[
'variables'
]).
to
include
(
*
expected_variables
)
expect
(
json_response
[
'features'
]).
to
eq
(
expected_features
)
end
context
'when job is made for tag'
do
...
...
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