Skip to content

[docs-scanner] GitLab example has confusing tag/branch logic #25082

@docker-agent

Description

@docker-agent

File: content/manuals/scout/integrations/environment/cli.md

Issue

The GitLab example has confusing conditional logic:

- |
  if [[ -z "$CI_COMMIT_TAG" ]]; then
    tag="latest"
    echo "Running tag '$CI_COMMIT_TAG'"
  else
    tag="$CI_COMMIT_REF_SLUG"
    echo "Running on branch '$CI_COMMIT_BRANCH'"
  fi    

When CI_COMMIT_TAG is empty (building a branch), it sets tag="latest" but echoes "Running tag '$CI_COMMIT_TAG'" (which is empty). When CI_COMMIT_TAG is NOT empty (building a tag), it sets tag="$CI_COMMIT_REF_SLUG" (which could be a branch or tag slug) and says "Running on branch".

The logic appears to conflate tags and branches, and the echo statements don't match what's actually happening.

Why this matters

A reader following this example would see:

  • Misleading echo output that doesn't match the actual values being used
  • Unclear logic about when to use "latest" vs the ref slug
  • Confusion about whether CI_COMMIT_REF_SLUG represents a tag or branch in the else case

Suggested fix

Clarify the logic to match the echo statements:

- |
  if [[ -z "$CI_COMMIT_TAG" ]]; then
    tag="$CI_COMMIT_REF_SLUG"
    echo "Running on branch '$CI_COMMIT_BRANCH'"
  else
    tag="$CI_COMMIT_TAG"
    echo "Running tag '$CI_COMMIT_TAG'"
  fi    
  echo "tag = $tag"

Or, if the intent is to use "latest" for branches:

- |
  if [[ -z "$CI_COMMIT_TAG" ]]; then
    tag="latest"
    echo "Running on branch '$CI_COMMIT_BRANCH'"
  else
    tag="$CI_COMMIT_TAG"
    echo "Running tag '$CI_COMMIT_TAG'"
  fi    
  echo "tag = $tag"

Found by nightly documentation quality scanner

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions