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

problems to config a gitlab-ci.yml file. config should implement a script: or a trigger: keyword

我正在尝试在 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

Git 实验室显示此错误:

这个Git实验室CI配置无效:jobs install-dependencies配置应该实现脚本:或触发器:关键字

示例由nx docs提供。我做错了什么?

This GitLab CI configuration is invalid: jobs install-dependencies config should implement a script: or a trigger: keyword

您需要将 script: 块添加到 install-dependencies

install-dependencies:
  stage: setup
  only:
    - develop
  script:
    - yarn install # or whatever you need to install your deps

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