赛普拉斯npm软件包已安装,但赛普拉斯二进制文件丢失

时间:2020-10-14 15:24:54

标签: javascript azure-devops continuous-integration pipeline cypress

大家好,我是azure devops CI的新手,我正在尝试通过在作业之间缓存node_modules来减少管道构建时间,但是我遇到了无法解决的错误。我正在使用赛普拉斯进行测试。 这是我的蔚蓝管道

# Node.js
# Build a general Node.js project with npm.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript

trigger:
- master

pool:
  vmImage: 'windows-2019'

variables:
  npm_config_cache: $(Pipeline.Workspace)/.npm
steps:
- task: NodeTool@0
  inputs:
    versionSpec: '10.x'
  displayName: 'Install Node.js'

- task: Cache@2
  inputs:
    key: 'npm | “$(Agent.OS)” | $(Build.SourcesDirectory)/package-lock.json'
    path: '$(Build.SourcesDirectory)/node_modules'
    cacheHitVar: 'CacheRestored'

- script: npm install
  displayName: 'npm install '
  condition: ne(variables['CacheRestored'], 'true')
  
- task: Npm@1
  inputs:
    command: 'custom'
    customCommand: 'run scripts'
  continueOnError: false  
  displayName: 'Npm run test'

- task: PublishBuildArtifacts@1
  displayName: "Publish Artifact: cypress-and-azure-devops Screenshots"
  inputs:
    PathtoPublish: cypress/screenshots
    ArtifactName: CypressAndAzureDevopsTestRunScreenshots
  condition: failed()

- task: PublishBuildArtifacts@1
  displayName: "Publish Artifact: cypress-and-azure-devops Videos "
  inputs:
    PathtoPublish: cypress/videos
    ArtifactName: CypressAndAzureDevopsTestRunVideos
  condition: succeededOrFailed()

- task: PublishTestResults@2
  displayName: "Publish Test Results"
  condition: succeededOrFailed()
  inputs:
    testResultsFormat: "JUnit"
    testResultsFiles: "**/cypress-and-azure-devops-*.xml"
    failTaskOnFailedTests: true

1 个答案:

答案 0 :(得分:0)

是否收到类似于以下内容的错误消息?

The cypress npm package is installed, but the Cypress binary is missing.
We expected the binary to be installed here: /xxx/.cache/Cypress/4.8.0/Cypress/Cypress
Reasons it may be missing:
- You're caching 'node_modules' but are not caching this path: /xxx/.cache/Cypress
- You ran 'npm install' at an earlier build step but did not persist: /root/.cache/Cypress
Properly caching the binary will fix this error and avoid downloading and unzipping Cypress.
Alternatively, you can run 'cypress install' to download the binary again.

如果是这样,根据错误日志,它提供了解决此问题的方法。您可以尝试再次运行cypress install命令来解决该问题。这是您可以参考的case

此外,“$(Agent.OS)”的引号应类似于"$(Agent.OS)"。或者,您可以选择在self-hosted代理中运行作业,机器级别的缓存和配置会在每次运行时保持不变,这可以提高速度。