Skip to content

Fix multi-line "script" commands in ".gitlab-ci.yml"

Multi-line .gitlab-ci. commands aren't executed correctly. Specifically the multi-line oc tag ... command in the import_image_to_openshift stage.

Testing locally with gitlab-runner exec docker import_image_to_openshift (install here), acutally gives correct results for the following styles:

# ">", indentation and backslahes "\"
script:
  - >
    oc tag \
      --source=docker \
      ${CI_REGISTRY_IMAGE}/${APPLICATION_IMAGE_NAME}:${VERSION} \
      ${APPLICATION_IMAGE_NAME}:${VERSION} \
      --token ${TOKEN} \ 
      --server=${OPENSHIFT_SERVER} \
      -n ${OPENSHIFT_PROJECT_TAGS_NAME}

# No ">" and no indentation
script:
  - oc tag
    --source=docker
    ${CI_REGISTRY_IMAGE}/${APPLICATION_IMAGE_NAME}:${VERSION}
    ${APPLICATION_IMAGE_NAME}:${VERSION}
    --token ${TOKEN}
    --server=${OPENSHIFT_SERVER}
    -n ${OPENSHIFT_PROJECT_TAGS_NAME}