GitLab流水线运行Microsoft Playwright测试时遇‘shell not found’错误
GitLab Playwright流水线出现"shell not found"错误的解决办法
问题原因
你使用的mcr.microsoft.com/playwright:v1.41.1-jammy镜像默认shell环境与GitLab CI Runner默认期望的shell不匹配,导致触发"shell not found"错误。
修复方案
在你的tests作业中明确指定shell路径,修改后的YAML配置如下:
stages: - test tests: rules: - when: manual stage: test image: mcr.microsoft.com/playwright:v1.41.1-jammy shell: /bin/bash # 新增该行指定执行shell script: - npm ci - npx playwright test artifacts: paths: - playwright-report - test-results - results.xml/ when: always expire_in: 120 days reports: junit: results.xml
如果上述方法无效,可尝试指定/bin/sh作为shell:
shell: /bin/sh
补充说明
基于Ubuntu Jammy的Playwright镜像同时包含bash和sh,指定任意一个都能解决shell匹配问题。若后续脚本包含bash专属语法,优先选择/bin/bash。
内容的提问来源于stack exchange,提问作者tedtrain
相关产品推荐
相关产品推荐

