Maj*_*ajd 5 javascript continuous-integration pipeline azure-devops cypress
大家好,我是 azure devops CI 的新手,我正在尝试通过在作业之间缓存 node_modules 来减少管道构建时间,但我遇到了无法解决的错误。我正在使用 cypress 进行测试。\n这是我的 azure 管道
\n# Node.js\n# Build a general Node.js project with npm.\n# Add steps that analyze code, save build artifacts, deploy, and more:\n# https://learn.microsoft.com/azure/devops/pipelines/languages/javascript\n\ntrigger:\n- master\n\npool:\n vmImage: 'windows-2019'\n\nvariables:\n npm_config_cache: $(Pipeline.Workspace)/.npm\nsteps:\n- task: NodeTool@0\n inputs:\n versionSpec: '10.x'\n displayName: 'Install Node.js'\n\n- task: Cache@2\n inputs:\n key: 'npm | \xe2\x80\x9c$(Agent.OS)\xe2\x80\x9d | $(Build.SourcesDirectory)/package-lock.json'\n path: '$(Build.SourcesDirectory)/node_modules'\n cacheHitVar: 'CacheRestored'\n\n- script: npm install\n displayName: 'npm install '\n condition: ne(variables['CacheRestored'], 'true')\n \n- task: Npm@1\n inputs:\n command: 'custom'\n customCommand: 'run scripts'\n continueOnError: false \n displayName: 'Npm run test'\n\n- task: PublishBuildArtifacts@1\n displayName: "Publish Artifact: cypress-and-azure-devops Screenshots"\n inputs:\n PathtoPublish: cypress/screenshots\n ArtifactName: CypressAndAzureDevopsTestRunScreenshots\n condition: failed()\n\n- task: PublishBuildArtifacts@1\n displayName: "Publish Artifact: cypress-and-azure-devops Videos "\n inputs:\n PathtoPublish: cypress/videos\n ArtifactName: CypressAndAzureDevopsTestRunVideos\n condition: succeededOrFailed()\n\n- task: PublishTestResults@2\n displayName: "Publish Test Results"\n condition: succeededOrFailed()\n inputs:\n testResultsFormat: "JUnit"\n testResultsFiles: "**/cypress-and-azure-devops-*.xml"\n failTaskOnFailedTests: true\nRun Code Online (Sandbox Code Playgroud)\n
您是否收到类似以下内容的错误消息?
\nThe cypress npm package is installed, but the Cypress binary is missing.\nWe expected the binary to be installed here: /xxx/.cache/Cypress/4.8.0/Cypress/Cypress\nReasons it may be missing:\n- You\'re caching \'node_modules\' but are not caching this path: /xxx/.cache/Cypress\n- You ran \'npm install\' at an earlier build step but did not persist: /root/.cache/Cypress\nProperly caching the binary will fix this error and avoid downloading and unzipping Cypress.\nAlternatively, you can run \'cypress install\' to download the binary again.\nRun Code Online (Sandbox Code Playgroud)\n如果是这样,根据错误日志,它提供了解决此问题的方法。您可以尝试再次运行 cypress install 命令来解决问题。这里有一个案例你可以参考一下。
\n另外, 的引号\xe2\x80\x9c$(Agent.OS)\xe2\x80\x9d应该是这样的"$(Agent.OS)"。或者,您可以选择在自托管代理中运行作业,机器级缓存和配置在每次运行中都会保留,这可以提高速度。
| 归档时间: |
|
| 查看次数: |
9632 次 |
| 最近记录: |