I'm trying to figure out how to set up a service connection to our company's gitlab instance in order to build and push some docker images on the gitlab container registry
I've created a service connection of type docker registry like this:
- Docker registry:
https://our_company_registry/project_name
- Docker ID: my gitlab username
- Docker password: my gitlab token with
read_registry
andwrite_registry
permissions - Service name:
Gitlab_Registry
my azure pipeline is
trigger:
- test
resources:
- repo: self
variables:
tag: '$(Build.BuildId)'
name: $(Date:yyyyMMdd)$(Rev:.r)
stages:
- stage: Build
displayName: Build image
jobs:
- job: Build
displayName: Build
pool:
vmImage: 'ubuntu-latest'
steps:
- task: Docker@2
displayName: Login to Gitlab_Registry
inputs:
command: login
containerRegistry: 'Gitlab_Registry'
- task: Docker@2
displayName: Build and push MyProject
inputs:
command: buildAndPush
repository: 'myproject'
containerRegistry: 'Gitlab_Registry'
dockerfile: '$(Build.SourcesDirectory)/src/MyProject/Dockerfile'
buildContext: '$(Build.SourcesDirectory)'
tags: '$(Build.BuildNumber)'
(I'm not even so sure about the login step...)
In devops, the build is successful but I got this error when is time to push the image
denied: requested access to the resource is denied
##[error]denied: requested access to the resource is denied
##[error]The process '/usr/bin/docker' failed with exit code 1
What am I missing?