13

I have a bitbucket pipelines yml that I have step for running my test script and a step to run a serverless deploy script. Do I need to npm install at each step or will the first npm install carry through and suffice for each subsequent step. Further than that, what is happening under the hood? I know Docker container is created; does each step just update the container?

- step:
        name: Test and Build
        script: 
          - npm install --no-package-lock
          - npm run test
    - step:
        name: Deploy Serverless
        script:
          - npm i serverless -g
          - npm install --no-package-lock
          - npm run deploy
ardev
  • 653
  • 2
  • 6
  • 19

2 Answers2

10

Can you implement it like the documentation: https://confluence.atlassian.com/bitbucket/caching-dependencies-895552876.html

The functionality is there. Let me know if it doesn't work for you still.

Mihai
  • 9,526
  • 2
  • 18
  • 40
8

Each step in the pipe creates a separate docker container which pulls in your branch. Using the cache option will allow your pipe to skip the install when building the container for the second step by pulling node_modules from the cache. You must still include the npm install line in each step to tell the pipe to use the cache if it exists.

Jeremy
  • 1,746
  • 1
  • 15
  • 20