Score:1

How to tag docker image with git commit code short id, in azure devops?

cn flag

I saw few links where I can tag my docker image using ${Build.SourceVersion} in azure devops pipeline.

But it is using the complete ID of the commit.

But I want to use only the short ID.

I mean this (2cc7968) instead of this (2cc79689fc29ad69698d3062688e2a650da62b8e)

How to get this?

My pipeline:

# Deploy to Azure Kubernetes Service
# Build and push image to Azure Container Registry; Deploy to Azure Kubernetes Service
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker

trigger:
  - master

resources:
  - repo: self

variables:
  # Container registry service connection established during pipeline creation
  dockerRegistryServiceConnection: "685f0716-8b46-436e-8d2a-3d0ff987fce9"
  imageRepository: "azuredevopssampleapp"
  containerRegistry: "aksdevopsacrtesting.azurecr.io"
  dockerfilePath: "**/Dockerfile"
  tag: "$(Build.BuildId)"
  imagePullSecret: "aksdevopsacrtesting458647f2-auth"

  # Agent VM image name
  vmImageName: "ubuntu-latest"

stages:
  - stage: Build
    displayName: Build 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)
          - upload: pipeline_content/manifests
            artifact: manifests
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.