Azure管道-在容器中执行其中一个阶段
我们的组织已开始迁移到Azure。 我们有Azure管道模板,它在Azure管道-在容器中执行其中一个阶段,azure,azure-pipelines-build-task,azure-pipelines-yaml,azure-pipelines-tasks,Azure,Azure Pipelines Build Task,Azure Pipelines Yaml,Azure Pipelines Tasks,我们的组织已开始迁移到Azure。 我们有Azure管道模板,它在vmImage:'ubuntu-18.04'上运行签出、构建和部署阶段。 我们的计划是在模板中引入“测试”阶段,并在容器中运行测试 问题: 当整个管道在vmImage上运行时,是否可以在容器中运行其中一个阶段(测试) 如何从vmImage复制构建工件以在容器中运行测试 有人能解释一下吗 非常感谢 当整个管道在vmImage上运行时,是否可以在容器中运行其中一个阶段(测试) 在Azure Devops Yaml管道中,您可以在作
vmImage:'ubuntu-18.04'
上运行签出、构建和部署阶段。
我们的计划是在模板中引入“测试”阶段,并在容器中运行测试
问题:
- 当整个管道在
上运行时,是否可以在容器中运行其中一个阶段(测试)vmImage
- 如何从vmImage复制构建工件以在容器中运行测试
容器
然后作业可以在目标容器上运行
以下是详细信息
如何从vmImage复制构建工件以在容器中运行测试
在前一阶段中,您可以使用发布构建工件任务
发布构建工件
在阶段(在容器中运行作业)中,您可以使用下载构建工件
任务将工件下载到容器中
最后,您可以添加测试步骤
这是我的样本:
resources:
containers:
- container: python
image: python:3.8
trigger:
- none
stages:
- stage: artifacts
pool:
vmimage: ubuntu-latest
jobs:
- job: test123
steps:
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.Sourcesdirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
- script: echo $(System.ArtifactsDirectory)
- stage: testcontainer
jobs:
- job: test123
container: python
steps:
- task: DownloadBuildArtifacts@0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'drop'
downloadPath: '$(System.ArtifactsDirectory)'
- script: |
echo $(System.ArtifactsDirectory)
displayName: 'Run a multi-line script'
注意:容器映像来自Docker Hub、Azure容器注册表或其他私有容器注册表
当整个管道在vmImage上运行时,是否可以在容器中运行其中一个阶段(测试)
在Azure Devops Yaml管道中,您可以在作业级别指定容器
然后作业可以在目标容器上运行
以下是详细信息
如何从vmImage复制构建工件以在容器中运行测试
在前一阶段中,您可以使用发布构建工件任务
发布构建工件
在阶段(在容器中运行作业)中,您可以使用下载构建工件
任务将工件下载到容器中
最后,您可以添加测试步骤
这是我的样本:
resources:
containers:
- container: python
image: python:3.8
trigger:
- none
stages:
- stage: artifacts
pool:
vmimage: ubuntu-latest
jobs:
- job: test123
steps:
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.Sourcesdirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
- script: echo $(System.ArtifactsDirectory)
- stage: testcontainer
jobs:
- job: test123
container: python
steps:
- task: DownloadBuildArtifacts@0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'drop'
downloadPath: '$(System.ArtifactsDirectory)'
- script: |
echo $(System.ArtifactsDirectory)
displayName: 'Run a multi-line script'
注意:容器映像来自Docker Hub、Azure容器注册表或其他私有容器注册表。Hi@Yamuna。这张票有更新吗?如果答案能给你一些帮助,请随时告诉我。只是提醒一下。嗨@Kevin Lu MSFT,非常感谢您的回复。我正在尝试你推荐的解决方案。我会在更新后尽快发布。嗨@Yamuna。为了跟进,您能否与我们分享最新信息?请随时告诉我答案是否可行。嗨@Yamuna。这张票有更新吗?如果答案能给你一些帮助,请随时告诉我。只是提醒一下。嗨@Kevin Lu MSFT,非常感谢您的回复。我正在尝试你推荐的解决方案。我会在更新后尽快发布。嗨@Yamuna。为了跟进,您能否与我们分享最新信息?请随时告诉我答案是否可行。谢谢你的解决方案。很抱歉延迟回复。我以类似的方式实现了它。而不是PublishBuildArtifacts@1及DownloadBuildArtifacts@0,我用过PublishPipelineArtifact@1及DownloadPipelineArtifact@2Thank您需要解决方案。很抱歉延迟回复。我以类似的方式实现了它。而不是PublishBuildArtifacts@1及DownloadBuildArtifacts@0,我用过PublishPipelineArtifact@1及DownloadPipelineArtifact@2