gitlab-ci

How do I get parts of my GitLab CI Job Log to fold when viewed on the GUI?


I have several GitLab CI Jobs which take a while to run. I already use the before_script and after_script features to break some of the work into sections. I would like to add further collapsible log sections within the Job output if that is possible.

Example of Collapsible Job Output as provided by GitLab

The job sections I can view presently on the GitLab web-interface include timings for each of the collapsible sections shown (see above image). If I could get more granular timings for each of the new sections created that would be a nice bonus but it is not essential.

I am currently using GitLab Community Edition 12.6.4


I tried looking through the GitLab CI/CD Pipeline Configuration Reference but I could not find and notes on defining your own sub-sections within the log output. I found an issue requesting a Collapsible Job Log which does include some suggesting workarounds for adding it but as that issue is closed I thought there was perhaps a more official way than messing with the DOM. I would prefer to go with an answer of "it is not supported" then make a rob for my own back by doing anything too strange with the output that might break in the future.


Solution

  • Were you looking for something like this?

    - echo -e "section_start:`date +%s`:my_first_section\r\e[0KHeader of the 1st collapsible section"
    - echo 'this line should be hidden when collapsed'
    - echo -e "section_end:`date +%s`:my_first_section\r\e[0K"
    

    as seen here https://docs.gitlab.com/ee/ci/yaml/script.html#custom-collapsible-sections