Is Yarn supported for bitbucket-pipelines caching?

I've been using the node cache feature for some time now and have been using yarn to load my load modules with the following pipeline snippet:

pipelines: 
default:
-
step:
caches:
-
node
script:
- yarn install
.
.
.

Observing the performance over several pipelines I haven't noticed any reduction in load time. I'm aware that the cache may not trigger for every pipeline, but I wanted to know if using yarn instead of npm is currently supported or is planned to be supported by pipelines caching.

1 answer

0 vote

Hi Shane, can you confirm if you're managing your dependencies correctly as explained at Manage dependencies with Yarn.

Cheers,

Ana 

I can't reply for Shane, but I am following the same process outlined in the doc you linked to, but am not seeing any benefits either. I believe I used to before but it's been a while since I noticed no benefits. At this time, my `yarn install`s take over half a minute despite the cache.

Incidentally, at the bottom I see `Cache "node": Skipping upload for previously downloaded cache`

Once install.sh is downloaded and executed, it will check if Yarn is already installed, if it does it'll just continue to the next script. FYI the script has 6.71 KB in size, so there's not too much to download :)

 

Cheers.

I think these answers are missing the point.

This isn't about Bitbucket caching the yarn installation... it's about caching the modules that yarn installs... the dependencies of the project being built.

I routinely see my `yarn install`s taking ~3m... they should take less than a second if my node_modules directory was being cached properly

I did swap to npm install just for pipeline builds for the reduction in build times, but still use yarn install for my dev environment/production. 

After playing around a bit, I've found that the following currently works

pipelines:
  default:
    - step:
        name: Build
        image: node:6.11.4
        caches:
          - yarncustom
        script:
          - curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.3.2
          - export PATH=$HOME/.yarn/bin:$PATH
          - yarn
          - yarn build
definitions:
  caches:
    yarncustom: /usr/local/share/.cache/yarn/v1

I got here by executing "yarn cache dir" on a Bitbucket Pipeline and then just setup a custom cache as per the documentation. I then executed my build subsequent times with "yarn --verbose". I was able to confirm that builds were using the cache by seeing if it needed to download the modules again.

@Jake Ben Thanks that worked for me too and double checked like you did. The cache download time is almost as slow as pulling from yarn but still a little boost.

Another point, the node docker image contains yarn so don't think there's a reason to install it via curl.. unless I'm missing something.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Marketplace Apps

Tips on how to choose the best estimation method for your planning

Planning and grooming sessions all come with their own sets of rules. Team members meet to estimate stories or other work items, all according to an agreed-upon process. And with every session comes ...

85 views 0 11
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you