【发布时间】:2022-01-18 16:54:27
【问题描述】:
我有一个 Azure DevOps 项目,其中有 2 个存储库,一个带有 .net Web 应用程序,另一个带有 Cypress 测试。我需要创建一个管道,从 Web 应用程序存储库构建和运行单元测试,然后签出赛普拉斯存储库并运行 e2e 测试。当我的管道尝试运行赛普拉斯测试时,我收到错误消息“赛普拉斯无法验证此服务器是否正在运行:https://localhost:5001/”
我相信因为我的 cypress 测试位于不同的存储库中,所以我需要让我的 web 应用程序在服务器上运行,直到我的 cypress 测试完成。这个对吗?我不确定,所以这是一个猜测。我该如何设置才能让我的测试正常运行?
这是我的管道 yaml 文件:
trigger:
- development
resources:
repositories:
- repository: e2ecypress
type: git
name: devopsapp/e2ecypress
jobs:
- job: build_unit_tests
displayName: '.Net Build'
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- job: cypress_tests
displayName: 'Cypress Tests'
pool:
vmImage: 'windows-latest'
steps:
- checkout: e2ecypress
- task: NodeTool@0
inputs:
versionSpec: '14.x'
displayName: 'Install Node.js'
- task: Npm@1
inputs:
command: 'install'
displayName: 'NPM Install'
- script: |
npx cypress run
displayName: 'Cypress Tests'
这是我的管道运行的错误:
【问题讨论】:
-
也许您可以在这里查看我对您之前的问题的评论:stackoverflow.com/a/70681905/6135684
-
@SebastianoVierk 我目前正在尝试这种方法。管道中的每个作业都会获得一个全新的虚拟机。这可能是我的问题吗?在我的应用程序构建之后,它会删除 vm,然后为 cypress 创建一个新的。我的 cypress 应用程序是否需要使用与 .net 作业相同的虚拟机?
标签: azure azure-devops continuous-integration azure-pipelines cypress