erSitzt
December 28, 2020, 12:50pm
1
Hi,
i’m trying to use collapsible sections like described here Jobs | GitLab , but it seems other than stated in the documentation the lines are not removed from the rendered output.
The first variant is directly from the documentation, the second one was just to change color…
Here’s the html for those lines
Any idea why those are not hidden ?
I’m not sure what i’m doing wrong
kihyoun
December 30, 2020, 11:08am
2
Hi, please post the .gitlab-ci.yml Part of the configuration and your current GitLab Version?
erSitzt
December 30, 2020, 1:03pm
3
Hi,
sure this is one example where it happens
And GitLab is current Version 13.7.1 (c97c8073a0e)
build_image_docker:
stage: build-docker
image: srv-nexus-oss.mydomain.com/docker:latest
services:
- docker:dind
script:
- echo -e "section_start:`date +%s`:before_script_section[collapsed=true]\r\e[0K\e[0K\e[33;1mBuilding Docker Image"
- echo "{\"name\":\"`echo $CI_PROJECT_DIR | cut -d'/' -f 7-`\",\"version\":\"$CI_BUILD_REF_NAME\",\"build_nr\":\"$CI_BUILD_ID\",\"build_date\":\"`date`\"}" >> ci-build.json
- cat ci-build.json
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- echo $DOCKERREGISTRY_PWD | docker login -u k8s --password-stdin $URL_DOCKERREGISTRY
- docker pull -q $DOCKER_IMAGE_NAME_LATEST || true
- docker build --cache-from ${DOCKER_IMAGE_NAME_LATEST} --build-arg env=$CI_COMMIT_REF_NAME -t ${DOCKER_IMAGE_NAME_FULL} -f ./Dockerfile .
- docker tag ${DOCKER_IMAGE_NAME_FULL} ${DOCKER_IMAGE_NAME_LATEST}
- docker push $DOCKER_IMAGE_NAME_FULL
- docker push $DOCKER_IMAGE_NAME_LATEST
- echo -e "section_end:`date +%s`:before_script_section\r\e[0K"
interruptible: true
tags:
- kubernetes
rules:
- if: $CI_MERGE_REQUEST_IID
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH
erSitzt
December 30, 2020, 1:07pm
4
And this is the other part from my screenshot
before_script:
- echo -e "section_start:`date +%s`:before_script_section[collapsed=true]\r\e[0KRunning before_script"
- mkdir -p /tmp
- export VAULT_ADDR=https://vault.mydomain.com
- export VAULT_TOKEN="$(vault write -field=token auth/jwt/login role=terraform jwt=$CI_JOB_JWT)"
- echo -e "section_end:`date +%s`:before_script_section\r\e[0K"
Not sure, but I think you don’t need the second clear ANSI Escape Code before adding a Color
Consider the building Docker Image section output:
- echo -e "section_start:`date +%s`:before_script_section[collapsed=true]\r\e[0K\e[0K\e[33;1mBuilding Docker Image"
\e[0K
removes some control char, probably the one which would normally hide this line. Remove one \e[0K
and try:
- echo -e "section_start:`date +%s`:before_script_section[collapsed=true]\r\e[0K\e[33;1mBuilding Docker Image"
I’m having the same issue, could it be because the docker container is using /bin/sh, and doesn’t have the support for escape sequences like in Bash?
I tried this suggestion, but it didn’t help. I’m suspecting it’s to do with the terminal in the container doing something with the escape sequences. Tried using echo and printf, but no difference.
allx
September 9, 2021, 1:46pm
8
After series of experiments, it seems that I found a way to make it work!
this one doesn’t hide the ugly block:
build_front:
extends: .build_front_template
script:
- printf "\e[0Ksection_start:`date +%s`:execution_section_0[collapsed=true]\r\e[0KBuilding frontend\n"
- yarn build --version=${RELEASE_VERSION} --git_branch="${CI_COMMIT_REF_NAME}" --revision_number="${CI_COMMIT_SHA}"
- printf "section_end:`date +%s`:execution_section_0\r\e[0K"
while this one does!
build_front:
extends: .build_front_template
script:
- >
printf "\e[0Ksection_start:`date +%s`:execution_section_0[collapsed=true]\r\e[0KBuilding frontend\n"
yarn build --version=${RELEASE_VERSION} --git_branch="${CI_COMMIT_REF_NAME}" --revision_number="${CI_COMMIT_SHA}"
printf "section_end:`date +%s`:execution_section_0\r\e[0K"
P.S. Using printf instead of echo doesn’t make sense, so ignore it