azure - Azure 管道 - 在容器中执行阶段之一
问题描述
我们的组织已开始迁移到 Azure。我们有 Azure 管道模板,可以在vmImage: 'ubuntu-18.04'
. 我们的计划是在模板中引入“测试”阶段并在容器中运行测试。
问题:
- 当整个管道在运行时
vmImage
,是否可以在容器中运行其中一个阶段(测试)? - 如何从 vmImage 复制构建工件以在容器中运行测试?
有人可以对此有所了解吗?
非常感谢!
解决方案
当整个管道在 vmImage 上运行时,是否可以在 Container 中运行其中一个阶段(测试)?
在 Azure Devops Yaml Pipeline 中,您可以container
在作业级别指定。
然后该作业可以在目标容器上运行。
这是有关详细信息的文档。
如何从 vmImage 复制构建工件以在容器中运行测试?
在上一阶段,您可以使用Publish Build Artifacts task
.
在阶段(在容器中运行作业)中,您可以使用Download Build Artifacts
任务将工件下载到容器中。
最后,您可以添加测试它的步骤。
这是我的示例:
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 容器注册表或其他私有容器注册表。
推荐阅读
- if-statement - 如何使用主动下拉发布以过滤显示的数据?
- java - 如何使用“预测”Sgnature Def 在 Java 中加载 Tensorflow SavedModel?
- sql-server - 如何显示 DISTINCT 值 Group Wise
- c# - 在 .NET 核心中返回 HttpResponseMessage 时出错
- android - 更新到 androidx.appcompat:appcompat:1.1.0 后的语言更改问题
- hibernate - 在 Quarkus 中添加 Hibernate ORM Panache 时在测试中发生异常
- javascript - 设置动画持续时间的时刻
- unity3d - 统一为游戏视图添加分辨率
- spagobi - 运行新的 spagobi 应用程序 SBIErrorPage.title 时出错
- acumatica - Acumatica 中的 Muslti Select 控件未显示强制 (*) 符号