How to use gcloud command in tipical maven stage?

Hi,

I have a question when I implement a pipeline in gitlab-ci.yml
If I have a stage that runs certain things from maven, but it needs to authenticate with GCP and for this I need to run the command like that:

- gcloud auth activate-service-account --key-file .gcpserviceaccount.json --project=${GCP_PROJECT}

But the image of the stage maven: 3.6.0-jdk-11-slim does not have the google sdk, what is the way to do it?

  1. Make a new image FROM maven: 3.6.0-jdk-11-slim and install the google sdk
  2. Can it be otherwise?

My stage code

build_prod:
  stage: build_prod
  tags:
    - docker
  image: maven:3.6.0-jdk-11-slim
  environment:
    name: production
  variables:
    GOOGLE_APPLICATION_CREDENTIALS: .gcpserviceaccount.json
  script:
    - apt-get update && apt-get install -y git gettext
    - mkdir -p /root/.m2 && cp .m2.settings.xml /root/.m2/settings2.xml
    - envsubst < /root/.m2/settings2.xml > /root/.m2/settings.xml
    - gcloud auth activate-service-account --key-file .gcpserviceaccount.json --project=${GCP_PROJECT}
    - mvn install
    - mvn package
    - mvn deploy
  only:
    - master
  when: manual

Thank you very much

Please, any suggestion about that?

Thank you very much