You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 01:33:16