skip to Main Content

I have the following pipeline:

# .gitlab-ci.yml


stages:
  - build
  - push

build:
  stage: build
  services:
    - docker:dind
  image: docker:latest
  script:
    # Build the Docker image
    - docker build -t myfe:$CI_COMMIT_SHA .

push:
  stage: push
  image: bitnami/azure-cli
  script:
#    - echo $DOCKERHUB_PASSWORD | docker login -u $DOCKERHUB_USERNAME --password-stdin
    - echo $ACR_CLIENT_ID | docker login mycr.azurecr.io --username $ACR_CLIENT_ID --password-stdin
    # Push the Docker image to the ACR
    - docker push myfe:$CI_COMMIT_SHA
  only:
    - main
#  before_script:
#    - echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
  variables:
    DOCKERHUB_USERNAME: $DOCKERHUB_USERNAME
    DOCKERHUB_PASSWORD: $DOCKERHUB_PASSWORD

It results in the following error:

Using docker image sha256:373... for bitnami/azure-cli with digest bitnami/azure-cli@sha256:9128... ...
ERROR: 'sh' is misspelled or not recognized by the system.
Examples from AI knowledge base:
https://aka.ms/cli_ref
Read more about the command in reference docs

Any idea what this might mean?

2

Answers


  1. The bitnami/azure-cli has an entrypoint of az, so your script is running as az parameters.

    To solve this, you need to override the entrypoint using: entrypoint: [""] in your gitlab-ci.yml.

    For more info check: https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#override-the-entrypoint-of-an-image

    Login or Signup to reply.
  2. If you want to user an Azure CLI image for this .gitlab-ci.yml file, you should use the official Microsoft image instead:

    image: mcr.microsoft.com/azure-cli
    

    Works like a charm!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search