Zamień $(Build.SourceBranchName)na tag latest w poniższym pliku yml.

/// YML

trigger:
  paths:
    include:
      - src-others/PosnetAPI/**
      - src-others/PosnetAPI.Test/**
      - azure/docker/fiscal-printer-api/**

pr:
  paths:
    include:
      - src-others/PosnetAPI/**
      - src-others/PosnetAPI.Test/**
      - azure/docker/fiscal-printer-api/**

variables:
  buildConfiguration: 'Release'
  shouldPublishBuild: 'true'
  shouldPublishDocker: 'true'

stages:
  - stage: Build
    displayName: Build Stage
    jobs:
      - job: Build
        displayName: Build FiscalPrinterApi
        steps:
          - checkout: self
            lfs: false
            fetchDepth: 1
            fetchTags: false

          - task: UseDotNet@2
            inputs:
              packageType: 'sdk'
              version: '6.x'
              installationPath: $(Agent.ToolsDirectory)/dotnet

          - task: DotNetCoreCLI@2
            displayName: 'Restore Dependencies'
            inputs:
              command: 'restore'
              projects: |
                src-others/PosnetAPI/FiscalPrinterApi.csproj
                src-others/PosnetAPI.Test/PosnetAPI.Test.csproj

          - task: DotNetCoreCLI@2
            displayName: 'Build FiscalPrinterApi'
            inputs:
              command: 'build'
              projects: 'src-others/PosnetAPI/FiscalPrinterApi.csproj'
              arguments: '--configuration $(buildConfiguration) /clp:ErrorsOnly'

          - task: DotNetCoreCLI@2
            displayName: 'Publish FiscalPrinterApi'
            inputs:
              command: 'publish'
              projects: 'src-others/PosnetAPI/FiscalPrinterApi.csproj'
              arguments: '--configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)/FiscalPrinterApi --property WarningLevel=1 /clp:ErrorsOnly'

          - publish: $(Build.ArtifactStagingDirectory)/FiscalPrinterApi
            artifact: FiscalPrinterApi

  - stage: Test
    displayName: Test Stage
    dependsOn: Build
    jobs:
      - job: Test
        displayName: Test PosnetAPI.Test
        steps:
          - checkout: self

          - task: UseDotNet@2
            inputs:
              packageType: 'sdk'
              version: '6.x'
              installationPath: $(Agent.ToolsDirectory)/dotnet

          - task: DotNetCoreCLI@2
            displayName: 'Restore Test Dependencies'
            inputs:
              command: 'restore'
              projects: 'src-others/PosnetAPI.Test/PosnetAPI.Test.csproj'

          - task: DotNetCoreCLI@2
            displayName: 'Run Tests'
            inputs:
              command: 'test'
              projects: 'src-others/PosnetAPI.Test/PosnetAPI.Test.csproj'
              arguments: '--configuration $(buildConfiguration) --logger "console;verbosity=detailed" /clp:ErrorsOnly'

          - task: PublishTestResults@2
            displayName: 'Publish Test Results'
            inputs:
              testResultsFormat: 'JUnit'
              testResultsFiles: '**/TEST-*.xml'
              failTaskOnFailedTests: true

  - stage: Publish
    displayName: Publish Stage
    dependsOn: Test
    jobs:
      - job: PublishDocker
        displayName: Build and Push Docker Image
        steps:
          - checkout: self

          - task: Docker@2
            displayName: 'Build and push an image to container registry'
            inputs:
              command: buildAndPush
              containerRegistry: "d9c165d7-11b1-48eb-892b-9704cc3af295"
              repository: "fiscal-printer-api"
              Dockerfile: "azure/docker/fiscal-printer-api/dockerfile"
              buildContext: "$(Build.SourcesDirectory)"
              tags: |
                $(Build.BuildId)
                $(Build.SourceBranchName)
            condition: and(succeeded(), eq(variables['shouldPublishBuild'], 'true'), eq(variables['shouldPublishDocker'], 'true'))

          - script: |
              echo "##vso[build.addbuildtag]$(Build.BuildId)"
              echo "##vso[build.addbuildtag]$(Build.SourceBranchName)"
            displayName: 'Add Build Tags'
            condition: succeeded()