Paul
Paul

Reputation: 29

maven jib:build authentication

I have pipelines setup in ADO that build, containerize apps, push to acr and then deploy to k8s. This works fine but I want to use jib instead of having separate tasks and take advantage of the layering savings.

I've struggling to get this to work. The original pipelines were something like:

- task: Docker@2
  displayName: Build container
  inputs:
    enabled: true
    command: build
    repository: repo
    Dockerfile: Dockerfile
    buildContent: /
    tags: latest
# Push container
- task: Docker@2
  displayName: Publish container
  inputs:
    enabled: true
    command: push
    repository: repo
    containerRegistry: acr-login-private
    Dockerfile: Dockerfile
    buildContent: /
    tags: latest

The login details were managed by the containerRegistry setting linked to a service connection that had all the details.

I want to replace this by:

- task: Maven@4
  inputs:
    mavenPOMFile: "pom.xml"
    jdkVersionOption: 21
    goals: "-B clean deploy jib:build"

but obviously get some sort of auth issue returned as I have no way to specify login credentials:

{"errors":[{"code":"UNAUTHORIZED","message":"authentication required, visit https://aka.ms/acr/authorization for more information."}]}

Upvotes: 0

Views: 116

Answers (1)

Paul
Paul

Reputation: 29

Feel stupid now. I just needed a Docker login task:

  - task: Docker@2
    inputs:
      containerRegistry: 'acr-login-private'
      command: 'login'

Upvotes: 0

Related Questions