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"
说明
- 移除了多余的
pagesjob,既解决了语法错误,也不会影响GitLab Pages的发布流程 create-pagesjob中的pages: true已经完成Pages发布的核心配置,会自动将public目录的产物上传为Pages artifacts
内容的提问来源于stack exchange,提问作者Konstantinos Nikolaidis
相关产品推荐
相关产品推荐

