Azure devops Azure管道任务输入赢得';不接受变量

Azure devops Azure管道任务输入赢得';不接受变量,azure-devops,yaml,azure-pipelines,azure-pipelines-tasks,Azure Devops,Yaml,Azure Pipelines,Azure Pipelines Tasks,在azure管道yaml文件中,变量imgRepoName从gitRepoName中删除。所示为core/cqbapi的gitRepoName的bash回音;显示的imgRepoName的bash回显cqb api variables: vmImageName: 'ubuntu-18.04' gitRepoName: $(Build.Repository.Name) imgRepoName: $(basename $(gitRepoName)) - job: build_pus

在azure管道yaml文件中,变量
imgRepoName
gitRepoName
中删除。所示为
core/cqbapi
gitRepoName
的bash回音;显示的
imgRepoName
的bash回显
cqb api

variables:
  vmImageName: 'ubuntu-18.04'
  gitRepoName: $(Build.Repository.Name)
  imgRepoName: $(basename $(gitRepoName))

  - job: build_push_image
    pool:
      vmImage: $(vmImageName)
    steps:
      - task: Docker@2
        displayName: Build and Push image
        inputs:
          repository: imgRepoName
          command: buildAndPush
          containerRegistry: "coreContainerRegistry"
          tags: test2
问题:

当我编写
存储库时:“cqbapi”
作为docker任务的输入,它工作得很好,而直接使用变量(如上所示)不会在容器注册表中创建任何图像

另外,我还尝试了
repository:$(imgRepoName)
它给出了以下错误

invalid argument "***/$(basenamecore/cqb-api):test2" for "-t, --tag" flag: invalid reference format

看起来它是在运行时执行的。因此,将替换
gitreponame
,但在此上下文中无法识别basename函数。您可以检查以下内容:

variables:
  gitRepoName: $(Build.Repository.Name)

steps:
- task: PowerShell@2
  inputs:
    targetType: 'inline'
    script: |
        $name = $(basename $(gitRepoName))
        Write-Host "##vso[task.setvariable variable=imgRepoName]$name"

- task: Docker@2
  displayName: Build and Push
  inputs:
    repository: $(imgRepoName)
    command: build
    Dockerfile: docker-multiple-apps/Dockerfile
    tags: |
      build-on-agent


这对我有用。

你的问题解决了吗?你可能认为这是解决你问题的最好办法。