Uploaded image for project: 'Bitbucket Cloud'
  1. Bitbucket Cloud
  2. BCLOUD-23246

Preserve directory structure when using a wildcard in the cache path

    • Our product teams collect and evaluate feedback from a number of different sources. To learn more about how we use customer feedback in the planning process, check out our new feature policy.

      Problem Definition

      Assume a project with dependencies in the following directories:

      • packages/componentA/dist
      • packages/componentB/dist

      If we use one cache definition with a wildcard as follows

      definitions:
        caches:
          build-cache: packages/**/dist

      or

      definitions:
        caches:
          build-cache:
            key:
             files:
               - package.json
            path: packages/**/dist

      the result is that a directory named ** will be created inside the packages directory, and then one directory named dist will be created inside the directory ** which will contain the files of both packages/componentA/dist and packages/componentB/dist. The directory structure is not preserved in the cache.

      Multiple cache definitions can be used, one for each directory. However, if the number of components (and directories to be cached) is large, the yml file will become quite large.

      Suggested Solution

      When using a wildcard in the cache path, preserve the structure of the directories that are cached.

      Workaround

      Multiple cache definitions can be used, one for each directory as follows:

      definitions:
        caches:
          build-cache:
            key:
             files:
               - package.json
            path: packages/componentA/dist
          build-cache2:
            key:
             files:
               - package.json
            path: packages/componentB/dist

          Form Name

            [BCLOUD-23246] Preserve directory structure when using a wildcard in the cache path

            Davide Lucchin added a comment - - edited

            This prevents using wildcards on windows self hosted runners as cache keys, I would escalate to BUG and not suggestion.
            BBS-229433

            Davide Lucchin added a comment - - edited This prevents using wildcards on windows self hosted runners as cache keys, I would escalate to BUG and not suggestion. BBS-229433

              Unassigned Unassigned
              tboudale Theodora Boudale
              Votes:
              3 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated: