Skip to content

[docs-scanner] Circle CI example has inverted tag/branch logic #25081

@docker-agent

Description

@docker-agent

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

Issue

The Circle CI example has inverted conditional logic that would cause it to use the wrong variable:

- run: |
    if [[ -z "$CIRCLE_TAG" ]]; then
      tag="$CIRCLE_TAG"
      echo "Running tag '$CIRCLE_TAG'"
    else
      tag="$CIRCLE_BRANCH"
      echo "Running on branch '$CI_COMMIT_BRANCH'"
    fi    

The condition -z "$CIRCLE_TAG" means "if CIRCLE_TAG is empty" (i.e., building a branch, not a tag). But when CIRCLE_TAG is empty, the code sets tag="$CIRCLE_TAG" (empty) and says "Running tag". When CIRCLE_TAG is NOT empty (building a tag), it sets tag="$CIRCLE_BRANCH" and says "Running on branch".

Additionally, the else branch echoes $CI_COMMIT_BRANCH, which is a GitLab variable, not a Circle CI variable.

Why this matters

A reader copying this example would get incorrect behavior:

  • When building a tag, it would use the branch name instead of the tag
  • When building a branch, it would use an empty tag value
  • The echo statements would be misleading
  • The GitLab variable reference would be undefined in Circle CI

Suggested fix

Invert the conditional logic and fix the variable reference:

- run: |
    if [[ -z "$CIRCLE_TAG" ]]; then
      tag="$CIRCLE_BRANCH"
      echo "Running on branch '$CIRCLE_BRANCH'"
    else
      tag="$CIRCLE_TAG"
      echo "Running tag '$CIRCLE_TAG'"
    fi    
    echo "tag = $tag"

Found by nightly documentation quality scanner

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/scoutRelates to Docker Scout

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions