Isolated NPM cache feature

Issue #16 resolved
Leonid Kuzmin created an issue

When running concurrent npm installs it often fails due to using shared cache dir, there is a workaround for now: --cache argument. It would be better if plugin would have an option "use isolated cache" (or something like that) or even use isolated caches by default. It could be done through creating cache dir in bamboo build job dir, but it should not be visible for artifacts creator, or some temp dir could be created for each build, in this case it should be cleaned after install ends.

Comments (8)

  1. Marcin Oles

    Added an advanced option for npm task to use isolated cache.

    It would be difficult to have a shared cache directory for an entire build. For now enabling this option causes the task to create a tmp cache folder just for a single task execution. So if you use multiple npm tasks within one job, each of them will be assigned a separate cache dir.

  2. Jason Berry

    Per task execution doesn't seem optimal as doing multiple npm install executions in the same job would result in things being needlessly downloaded again. Seems like it would be better to do it per job, by creating a folder like .tmpNpmCache in the build directory?

    Seems like the problem is isolating the cache from other builds on the same agent, or even other builds of the same plan on the same agent – not cache isolation between tasks in the same job.

  3. Marcin Oles

    I'm not sure if adding any content to the build directory is a good idea - I wanted to avoid that, so I used a temporary folder. I know this is not exactly the best solution, as it would be better to have a cache dir shared between jobs (or even stages?). The main problem that this solution fixes though is:

    When running concurrent npm installs it often fails due to using shared cache dir (...)

    Nevertheless I'll try to implement it in a little bit better way - probably a shared tmp dir between tasks for a single job + a CustomBuildProcessor that cleans it afterwards.

  4. Marcin Oles

    Ok, now the cache directory is shared within one job and is removed after the job finishes.

    I had some issues with implementing similar logic for deployment projects, so for now for deployments the feature works as before (the directory is created & deleted within one task execution).

  5. Marcin Oles

    The final solution works for both deployments and builds. The cache directory is shared between npm tasks within one pipeline. For build plans the directory is deleted after the build finishes. For deployments it's not cleaned automatically (due to previously mentioned difficulties). The cache folder can be reused by next npm tasks run on the same agent (folder content gets cleaned first; so there will be at most one uncleaned cache directory on a running agent in it's temp dir).

  6. Log in to comment