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

Condition to skip a step if a cache with a certain hash exists

XMLWordPrintable

    • 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

      Some customers have a setup as follows:

      - step:
          name: Generate cache
          cache: custom-cache
          script:
            - yarn install
      - parallel:
        - step:
            cache: custom-cache
            script:
              - <...>
        - step:
            cache: custom-cache
            script:
              - <...> 
        - step:
            cache: custom-cache
            script:
              - <...>

       

      The first step is only generating a cache. This cache is needed by the next 3 parallel steps, which do not include the yarn install command to generate the cache.

      This is a cache with file-based cache keys based on the yarn.lock file.

       

      The problem in this case is that the first step gets executed even when the cache with the correct hash exists, and this takes time.

      A condition could be added in the first step with changesets - includePaths for the yarn.lock file, so that this step gets executed only when the yarn.lock file changes. However, since caches get cleared after a week, if the yarn.lock file doesn't get updated every week, then the rest of the steps will fail since they don't generate the cache.

      Suggested Solution

      The suggested solution is the ability to skip a step if a cache with the correct hash exists; have a condition to only run the step if the cache with the correct hash doesn't exist.

              Unassigned Unassigned
              tboudale Theodora Boudale (Inactive)
              Votes:
              15 Vote for this issue
              Watchers:
              10 Start watching this issue

                Created:
                Updated: