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

Time:05-05

Im trying to create my first CI on gitlab. I have a angular app, with nx-workspace (monorepo) and this is my fully ci file:

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 lab shows this error:

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

The example are offered by nx docs. Im doing something wrong?

CodePudding user response:

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

You need to add a script: block to install-dependencies

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

Otherwise, you would have the job install-dependencies defined, but you have no instructions for what that job should do.

  • Related