Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Can't cache Node nor Composer in Pipelines (& Deployment)

Arjan Oskam January 19, 2018

Hello everyone,

I have been trying to get Pipelines to work with caching, but I have not succeeded yet.

The cache is supposed to be built after a succesful pipelines, but it does not do that.
And everytime I run the pipelines again (with or without a new commit), it says:
Cache "composer": DownloadingCache
"composer": Not found
Cache "node": DownloadingCache
"node": Not found

And I can't seem to figure out what I am doing wrong here.

This is my configuration:

image: awhalen/docker-php-composer-node

pipelines:
   custom:
      Deploy to Acceptance:
         - step:
            deployment: staging
            script:
              - cd ..
              - rsync -vIauz --filter="merge build/filter.txt" build/ $ACC_USER@$ACC_HOST:$ACC_PATH
      Build & Deploy to Acceptance:
         - step:
            caches:
              - composer
              - node
            deployment: staging
            script:
              - cd pattern_lab
              - composer install
              - npm install
              - npm run build
              - cd ../..
              - rsync -vIauz --filter="merge build/filter.txt" build/ $ACC_USER@$ACC_HOST:$ACC_PATH

 Can anyone tell me what I am doing wrong here? I've ran the pipeline more than 10 times and the cache ceases to excist

2 answers

1 accepted

1 vote
Answer accepted
Arjan Oskam February 15, 2018

The problem was that the node_modules weren't in the root directory. So the standard cache definition of Pipelines couldn't find it.

Assigning a custom path solved the problem

vmurillo April 1, 2019

How do you add a custom path ?

Do you add a command with the custom path or do you change where bitbucket looks for the cache?

StannousBaratheon
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 1, 2019

You can define caches with custom paths in the definitions section of your yml file:

definitions:
  caches:
    mycustomcache: vendor/bundle

 https://confluence.atlassian.com/bitbucket/caching-dependencies-895552876.html

Like matheus.sartoretto likes this
1 vote
StannousBaratheon
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 21, 2018

Hi Arjan,

Is there anything in the "Build teardown" section of your log file?

Caches are limited to 1GB in size and if your artifacts exceed that the cache will not be created.

Another possibility if that your build is not configured to output to the default composer location: ~/.composer/cache

Can you please list the contents of this directory at the end of your build to assist in debugging?

Arjan Oskam January 21, 2018

Which directory do you want the content from?

This is in the "Build teardown" section:
Cache "composer": Skipping upload for empty cacheCache "node": Skipping upload for empty cacheSearching for test report files in directories named [test-results, failsafe-reports, test-reports, surefire-reports] down to a depth of 4Finished scanning for test reports. Found 0 test report files.

StannousBaratheon
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 22, 2018

The "composer" cache is a default cache that is configured to cache everything in the ~/.composer/cache directory.

The log message you posted from the teardown section indicates that there are no files in that directory: Cache "composer": Skipping upload for empty cache

You can verify this by listing the contents of the ~/.composer/cache directory at the end of your build. If this is not the location where your dependencies are located then you can either configure your build to output to that location or define a custom cache for a different location. Please see https://confluence.atlassian.com/bitbucket/caching-dependencies-895552876.html for details.

Arjan Oskam January 23, 2018

I found out what the problems were:
Composer: In my dockerimage there was a composer home
Node: The node_modules weren't in the root

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events