结合DockerCompose @ 0任务以在Azure管道中运行特定服务

时间:2020-06-02 11:55:38

标签: docker docker-compose azure-pipelines

我具有以下的蔚蓝管道,可为2个单元测试项目运行两个docker compose任务。

    - task: DockerCompose@0

      displayName: 'Run Application Unit Tests'

      inputs:

        containerregistrytype: 'Azure Container Registry'

        azureSubscription: $(azureSubscription)

        azureContainerRegistry: $(azureContainerRegistry)

        dockerComposeFile: '**/docker-compose.yml'

        action: 'Run a specific service'

        serviceName: 'application.tests'

        detached: false



    - task: DockerCompose@0

      displayName: 'Run Infrastructure Unit Tests'

      inputs:

        containerregistrytype: 'Azure Container Registry'

        azureSubscription: $(azureSubscription)

        azureContainerRegistry: $(azureContainerRegistry)

        dockerComposeFile: '**/docker-compose.yml'

        action: 'Run a specific service'

        serviceName: 'infrastructure.tests'

        detached: false



    - task: PublishTestResults@2

      displayName: 'Publish test results'

      inputs:

        testResultsFormat: 'VSTest'

        testResultsFiles: '/opt/vsts/work/_temp/*.trx'

        mergeTestResults: true

        failTaskOnFailedTests: true



    - task: PublishCodeCoverageResults@1

      displayName: 'Publish coverage report'

      inputs:

        codeCoverageTool: Cobertura

        summaryFileLocation: '/opt/vsts/work/_temp/*.cobertura.xml' 

这可以正常工作,并将测试和代码覆盖率结果组合在一起。但是我必须在单独的任务中定义管道中的每个单元测试项目。

是否有一种方法可以在一个天蓝色管道任务中为所有项目运行测试?

两个项目都在同一解决方案(.NET Core)中。我知道我可以在一个项目中进行测试,但想将关注点分开。

1 个答案:

答案 0 :(得分:1)

如果在撰写文件中配置了多个服务,则可以尝试使用Run service images操作。

enter image description here