I’m trying to create a pipeline in Azure Devops for an API project in NET 7, but I’m getting build error everytime, even with a fresh project with the base example of WeatherForecast.
I tried with Docker Windows, and downgrading the version of NET using NET 6, but it won’t work either.
I tried with different accounts so it’s not an auth problem, not even a version of NET problem, I think that is generating the yaml file in the incorrect way, this is the version of the NET 6 with Docker Linux:
trigger:
- master
resources:
- repo: self
variables:
dockerRegistryServiceConnection: '3cdd4a4c-****-****-****-132c5f7c77c0'
imageRepository: '****'
containerRegistry: 'directiocontainers.azurecr.io'
dockerfilePath: '$(Build.SourcesDirectory)/Test3Pipeline/Dockerfile'
tag: '$(Build.BuildId)'
vmImageName: 'ubuntu-latest'
stages:
- stage: Build
displayName: Build and push stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: Docker@2
displayName: Build and push an image to container registry
inputs:
command: buildAndPush
repository: $(imageRepository)
dockerfile: $(dockerfilePath)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
2
Answers
Most likely your build context is incorrect, try adding
buildContext: $(Build.SourcesDirectory)
right under the
containerRegistry: $(dockerRegistryServiceConnection)
line of your yml pipeline file.