我正在尝试在 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 实验室显示此错误:
此 GitLab CI 配置无效:作业安装依赖配置应实现脚本:或触发器:关键字
示例由 nx docs 提供。我做错了什么?
最佳答案
This GitLab CI configuration is invalid: jobs install-dependencies config should implement a script: or a trigger: keyword
你需要添加一个script:
block 到install-dependencies
install-dependencies:
stage: setup
only:
- develop
script:
- yarn install # or whatever you need to install your deps
否则,您将定义作业 install-dependencies
,但您没有关于该作业应该做什么的说明。
关于angular - 配置 gitlab-ci.yml 文件的问题。配置应执行脚本 : or a trigger: keyword,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72105205/