Home > OS >  How to delete an Azure Pipeline cache without changing cache key
How to delete an Azure Pipeline cache without changing cache key

Time:03-16

I have a task that creates a cache

- task: Cache@2
  inputs:
    key: 'sonarCache'
    path: $(SONAR_CACHE)
    cacheHitVar: CACHE_RESTORED
  displayName: Cache Sonar packages

However, the cache got corrupted. So how do I run this pipeline while telling it to ignore any existing cache ?

For some reason, I cannot change the cache key sonarCache

CodePudding user response:

Clearing a cache is currently not supported. However you can add a string literal (such as version2) to your existing cache key to change the key in a way that avoids any hits on existing caches. For example, change the following cache key from this:

key: 'sonarCache'

to this :

key: 'version2 | sonarCache'

And caches will expire after seven days of no activity.

  • Related