Pre-Collapsed Sections in CI Job Logs
What does this MR do?
This MR adds the ability to configure options for CI job log sections. The options for a section are defined in the section_start
as a one-dimensional key-value map in the format [option0=key0, option1=key1, ..., optionN=keyN]
.
The changes do not break current CI configurations because the options are optional (see this regexr pattern for explanation or the regex.rb file).
The MR also adds the collapsed
option (which will be the only option to configure, for now). By setting the option [collapsed=true]
, when viewing a job log, the section is collapsed initially but can be opened and closed by the user manually. This change is reflected in the documentation.
The changes to the frontend are minimal because the constant which was determining that all log sections are open by default will be replaced by determining the collapsed state from the logs. The changes to the backend mostly target the ansi2json
system because it's used for generating the json log sent to the browser.
A potential problem that this MR introduces is that one the collapsed
option is introduced, it can not be changed easily because users will use it in the CI configs. The section option logic, however, passes all options to the frontend and does not require changes for new options.
Relates to #198413 (closed).
Steps to test
To be able to test these changes, you need to:
- Go to a project with CI enabled (or set it up)
- Create a
.gitlab-ci.yml
with this or a similar job that contains a section with the options[collapsed=true]
job1:
script:
- echo -e "section_start:`date +%s`:my_first_section[collapsed=true]\r\e[0KHeader of the 1st collapsible section"
- echo 'this line should be hidden automatically after loading the job log'
- echo -e "section_end:`date +%s`:my_first_section\r\e[0K"
- Run a pipeline and check that only your created section is pre-collapsed.
Screenshots
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides - [-] Database guides
-
Separation of EE specific content
Availability and Testing
The changes add one test case for the frontend (job log utils) and two for the backend (both related to ansi2json
).
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers - [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- [-] Label as security and @ mention
@gitlab-com/gl-security/appsec
- [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
- [-] Security reports checked/validated by a reviewer from the AppSec team