我正在使用Azure Devops构建和推送我的Docker映像。使用Docker任务执行buildAndPush时如何传递参数?

我正在使用Azure Devops构建和推送我的Docker映像。使用Docker任务执行buildAndPush时如何传递参数?,docker,azure-devops,continuous-integration,Docker,Azure Devops,Continuous Integration,我已经创建了一个管道来构建Docker映像并将其推送到我的容器注册表。我使用Docker任务来完成这项工作(buildAndPush命令)。以下是“构建和推送”步骤的YAML片段: - task: Docker@2 displayName: Build and Push inputs: command: buildAndPush containerRegistry: dockerRegistryServiceConnection1 repository: cont

我已经创建了一个管道来构建Docker映像并将其推送到我的容器注册表。我使用Docker任务来完成这项工作(buildAndPush命令)。以下是“构建和推送”步骤的YAML片段:

- task: Docker@2
  displayName: Build and Push
  inputs:
    command: buildAndPush
    containerRegistry: dockerRegistryServiceConnection1
    repository: contosoRepository
    tags: latest
    arguments: --label buildtype=nightly

任务将忽略
参数
输入。如何将参数传递给Docker命令?

在Docker任务中使用
buildAndPush
命令时,将忽略
参数。由于这是两个Docker命令的组合,
参数
输入变得不明确

如果您想向build命令添加一些参数,可以拆分build并将其推进到两个单独的步骤中,如下所示:

- task: Docker@2
  displayName: Build
  inputs:
    command: build
    containerRegistry: dockerRegistryServiceConnection1
    repository: contosoRepository
    tags: latest
    arguments: --label buildtype=nightly

- task: Docker@2
  displayName: Push
  inputs:
    command: push
    containerRegistry: dockerRegistryServiceConnection1
    repository: contosoRepository
    tags: latest

伟大的谢谢你在这里分享你的解决方案,你可以,它可以帮助其他社区成员谁得到同样的问题,我们可以存档这个线程,谢谢。这正是我想要的。谢谢分享。