Hi guys assume this is my gitlab ci
.gitlab-ci.yml
stages:
- install
- build
before_script:
- nvm install 14.17
- nvm use 14.17
- npm install -g yarn@1.10.1 --registry=$NPM_REGISTRY
- npm install -g semantic-release
- git fetch --all
include: '/ci/install_stage.yml'
include: '/ci/build_stage.yml'
/ci/install_stage.yml
install:
stage: install
tags:
- fe
- xdev
artifacts:
expire_in: 1 day
paths:
- node_modules/
only:
changes:
- .gitlab-ci.yml
- package.json
- packages/**/*
script:
- yarn install
cache:
key: '$CI_PROJECT_PATH-package'
paths:
- $CI_PROJECT_DIR/node_modules/
/ci/build_stage.yml
build:
stage: build
tags:
- fe
- xdev
artifacts:
expire_in: 1 day
paths:
- $CI_PROJECT_DIR/dist
only:
changes:
- .gitlab-ci.yml
- package.json
- packages/**/*
script:
- yarn build
dependencies:
- install
cache:
key: '$CI_PROJECT_PATH-CI_COMMIT_REF_SLUG-build'
paths:
- $CI_PROJECT_DIR/dist
So basically i want to only run build
after install
, thats why i put a dependencies
in build
job. But then the lint give me error build job undefined dependency install
So it seem the lint of Gitlab is done invidually before the merge ?
anyway to fix this ? thanks
From the include
documentation :
The include files are:
Merged with those in the .gitlab-ci.yml file.
Always evaluated first and then merged with the content of the .gitlab-ci.yml file, regardless of the position of the include keyword.
So you can update your .gitlab-ci.yml
file like this, to evaluate all includes before merging, so the build
job will know your install
job :
stages:
- install
- build
...
include:
- '/ci/install_stage.yml'
- '/ci/build_stage.yml'