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

GitLab Pages配置报错:Jobs pages需实现script/run/trigger关键字

解决GitLab CI流水线语法错误:Jobs pages config should implement the script:, run:, or trigger: keyword

问题原因

你定义的pages job仅配置了artifacts,但GitLab CI要求每个job必须包含script、run或trigger中的至少一项作为执行逻辑,因此触发语法错误。另外,你已经在create-pages job中通过pages: true标记了这是Pages发布任务,该配置会自动将public目录的产物用于GitLab Pages发布,无需单独创建pages job。

修正后的.gitlab-ci.yml配置

default:
  image: ruby:3.2
  before_script:
    - gem install bundler
    - bundle config set path 'vendor'
  cache:
    paths:
      - vendor/

workflow:
  rules:
    - if: $CI_COMMIT_BRANCH

create-pages:
  stage: deploy
  script:
    - bundle exec jekyll build -d public
  pages: true  # 指定此任务为Pages发布任务,默认发布public目录
  rules:
    - if: $CI_COMMIT_BRANCH == "main"
  environment: production

test:
  stage: test
  script:
    - bundle exec jekyll build -d test
  artifacts:
    paths:
      - test
  rules:
    - if: $CI_COMMIT_BRANCH != "main"

说明

  • 移除了多余的pages job,既解决了语法错误,也不会影响GitLab Pages的发布流程
  • create-pages job中的pages: true已经完成Pages发布的核心配置,会自动将public目录的产物上传为Pages artifacts

内容的提问来源于stack exchange,提问作者Konstantinos Nikolaidis

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.13 15:04:51