I use GitLab CI for the project, and the first step of the process is npm install
. I cache node_modules
to start the same work more quickly later, and also define them as build artifacts to use them at later stages. However, even if I cache node_modules
and update by calling npm install
each time the install_packages
job is complete, it takes a lot of time, as the command goes through all package.json
and checks for package updates, etc. (suppose).
Is there a way to only run npm install
in the install_packages
job depending on some condition? More specifically (which, in my opinion, would be a better solution), has package.json
changed or not since the last build?
Below is the relevant part of my .gitlab-ci.yml file:
image: node:6.9.1 stages: - install - prepare - deploy install_packages: stage: install script: - npm prune - npm install cache: key: ${CI_BUILD_REF_NAME} paths: - node_modules/ artifacts: paths: - node_modules/ only: - master - develop build_and_test: stage: prepare script:
source share