配置 gitlab-ci.yml 文件时出现问题。配置应该实现一个脚本:或一个触发器:关键字

Flá*_*sta 7 yaml gitlab gitlab-ci angular

我正在尝试在 gitlab 上创建我的第一个 CI。我有一个 Angular 应用程序,带有 nx-workspace (monorepo),这是我的完整 ci 文件:

image: node:16-alpine
stages:
  - setup
  - test

install-dependencies:
  stage: setup
  only:
    - develop

.distributed:
  interruptible: true
  only:
    - develop
  needs: ["install-dependencies"]
  artifacts:
    paths:
      - node_modules/.cache/nx

workspace-lint:
  stage: test
  extends: .distributed
  script:
    - npx nx workspace-lint

format-check:
  stage: test
  extends: .distributed
  script:
    - npx nx format:check

lint:
  stage: test
  extends: .distributed
  script:
    - npx nx affected --base=HEAD~1 --target=lint --parallel=3

test:
  stage: test
  extends: .distributed
  script:
    - npx nx affected --base=HEAD~1 --target=test --parallel=3 --ci --code-coverage

build:
  stage: test
  extends: .distributed
  script:
    - npx nx affected --base=HEAD~1 --target=build --parallel=3
Run Code Online (Sandbox Code Playgroud)

Git 实验室显示此错误:

此 GitLab CI 配置无效:作业安装依赖项配置应实现脚本:或触发器:关键字

该示例由 nx 文档提供。我做错了什么吗?

syt*_*ech 3

此 GitLab CI 配置无效:作业安装依赖项配置应实现脚本:或触发器:关键字

您需要添加一个script:install-dependencies

install-dependencies:
  stage: setup
  only:
    - develop
  script:
    - yarn install # or whatever you need to install your deps
Run Code Online (Sandbox Code Playgroud)

否则,您将定义该作业install-dependencies,但没有该作业应该做什么的说明。