azure-pipelines-tasks: Cache: Unable to find pipeline caching scopes

Question, Bug, or Feature?
Type: Bug

Enter Task Name: CacheV2

Environment

  • Server - Azure Pipelines
  • Agent - Private: Windows Server 2016/1607, Agent 2.160.1

Issue Description

Receive an error “Unable to find pipeline caching scopes” when using Cache task.

azure-pipelines.yml:

...
stages:
- stage: Test
  jobs:
  - deployment: test
    pool: default
    environment: Test
    variables:
      NPM_CONFIG_CACHE: $(Pipeline.Workspace)/.npm
    strategy:
      runOnce:
        deploy:
          steps:
          ...
          - task: Cache@2
            displayName: Cache NPM
            inputs:
              key: 'npm | $(Agent.OS) | package-lock.json'
              path: $(NPM_CONFIG_CACHE)
          ...

Error logs

2019-12-02T21:45:53.7630220Z ##[debug]Evaluating condition for step: 'Cache NPM'
2019-12-02T21:45:53.7630992Z ##[debug]Evaluating: SucceededNode()
2019-12-02T21:45:53.7631158Z ##[debug]Evaluating SucceededNode:
2019-12-02T21:45:53.7631419Z ##[debug]=> True
2019-12-02T21:45:53.7631659Z ##[debug]Result: True
2019-12-02T21:45:53.7631868Z ##[section]Starting: Cache NPM
2019-12-02T21:45:53.7778695Z ==============================================================================
2019-12-02T21:45:53.7778813Z Task         : Cache
2019-12-02T21:45:53.7778891Z Description  : Cache files between runs
2019-12-02T21:45:53.7778956Z Version      : 2.0.0
2019-12-02T21:45:53.7779031Z Author       : Microsoft Corporation
2019-12-02T21:45:53.7779098Z Help         : https://aka.ms/pipeline-caching-docs
2019-12-02T21:45:53.7779198Z ==============================================================================
2019-12-02T21:45:54.2686344Z Resolving key:
2019-12-02T21:45:54.2911166Z  - npm               [string]
2019-12-02T21:45:54.2911326Z  - Windows_NT        [string]
2019-12-02T21:45:54.3596092Z  - package-lock.json [file] --> 893737D82F56FFDA8A2051D6B31DBEAB33C876C5D9B31C506D8D716EB77537E6
2019-12-02T21:45:54.3649403Z Resolved to: npm|Windows_NT|3vo3/xQdDCzX1Gctv/MAub1nI4omrNHa2GRQxcPB1xE=
2019-12-02T21:45:54.3689378Z ##[debug]Processed: ##vso[task.settaskvariable variable=RESTORE_STEP_RAN;issecret=False;]true
2019-12-02T21:45:54.6912021Z ##[debug]Dedup parallelism: 192
2019-12-02T21:45:54.9065002Z Information, ApplicationInsightsTelemetrySender will correlate events with X-TFS-Session f86a0648-92a5-4856-9459-ddf876237258
2019-12-02T21:45:54.9404675Z Information, Getting a pipeline cache artifact with one of the following fingerprints:
2019-12-02T21:45:54.9404875Z Information, Fingerprint: `npm|Windows_NT|3vo3/xQdDCzX1Gctv/MAub1nI4omrNHa2GRQxcPB1xE=`
2019-12-02T21:45:57.5599778Z Information, ApplicationInsightsTelemetrySender correlated 2 events with X-TFS-Session f86a0648-92a5-4856-9459-ddf876237258
2019-12-02T21:45:57.5658821Z ##[error]Unable to find pipeline caching scopes.
2019-12-02T21:45:57.5659251Z ##[debug]Processed: ##vso[task.logissue type=error;]Unable to find pipeline caching scopes.
2019-12-02T21:45:57.5659930Z ##[debug]Processed: ##vso[task.complete result=Failed;]
2019-12-02T21:45:57.5688850Z ##[debug]   at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.HandleResponseAsync(HttpResponseMessage response, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.SendAsync(HttpRequestMessage message, HttpCompletionOption completionOption, Object userState, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.SendAsync[T](HttpRequestMessage message, Object userState, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.SendAsync[T](HttpMethod method, IEnumerable`1 additionalHeaders, Guid locationId, Object routeValues, ApiResourceVersion version, HttpContent content, IEnumerable`1 queryParameters, Object userState, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.Services.PipelineCache.WebApi.PipelineCacheClient.GetPipelineCacheArtifactAsync(Fingerprint[] fingerprints, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.Services.PipelineCache.WebApi.PipelineCacheClient.<>c__DisplayClass9_0.<<GetPipelineCacheArtifactAsync>b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.VisualStudio.Services.BlobStore.Common.Telemetry.BlobStoreClientTelemetry.MeasureActionAsync[TResult](BlobStoreTelemetryRecord record, Func`1 actionAsync)
   at Microsoft.VisualStudio.Services.PipelineCache.WebApi.PipelineCacheClient.GetPipelineCacheArtifactAsync(Fingerprint[] fingerprints, CancellationToken cancellationToken, PipelineCacheTelemetryRecord cacheRecordOptional)
   at Agent.Plugins.PipelineCache.PipelineCacheServer.DownloadAsync(AgentTaskPluginExecutionContext context, Fingerprint[] fingerprints, String path, String cacheHitVariable, CancellationToken cancellationToken)
   at Agent.Plugins.PipelineCache.RestorePipelineCacheV0.ProcessCommandInternalAsync(AgentTaskPluginExecutionContext context, Fingerprint fingerprint, Func`1 restoreKeysGenerator, String path, CancellationToken token)
   at Agent.Plugins.PipelineCache.PipelineCacheTaskPluginBase.RunAsync(AgentTaskPluginExecutionContext context, CancellationToken token)
   at Agent.PluginHost.Program.Main(String[] args)
2019-12-02T21:45:57.5821100Z ##[section]Finishing: Cache NPM

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 9
  • Comments: 17 (3 by maintainers)

Most upvoted comments

I’m running into the same issue.

The task: Cache@2 works fine for the usual jobs, but throws this error when its used under:

jobs:
  - deployment: DeployJobName
    ...

Guys can you please work on fixing this?

It does not work in Releases, no.

Thanks. Are there any plans this task to be supported in Releases? It will be very useful for scheduled deployment jobs which always rely on the same dependencies. (e.g. PowerShell modules)

I’m hitting the exact same error as the OP. I’m using a similar (YAML-only) pipeline with a - deployment: job and an environment:. Similarly to @VOVELEE I’m only experiencing this since I’ve changed the job to a deployment job and used an environment. One peculiar thing though is: I’m having this stage in a template which is used by multiple pipelines and one works while another one doesn’t (I’ve not tested more than two of the pipelines).

@johnterickson @fadnavistanmay are you talking about Classic Release Pipelines or Deployment Jobs in multi-stage YAML Pipelines? According to the docs it should work for the latter:

I try using it in “- deployment” job in a multistaged yaml based pipeline with envs and it does not work! It’s a shame

As of now, there are no plans to make it available for Releases.

I’m hitting the exact same error as the OP. I’m using a similar (YAML-only) pipeline with a - deployment: job and an environment:. Similarly to @VOVELEE I’m only experiencing this since I’ve changed the job to a deployment job and used an environment. One peculiar thing though is: I’m having this stage in a template which is used by multiple pipelines and one works while another one doesn’t (I’ve not tested more than two of the pipelines).

@johnterickson @fadnavistanmay are you talking about Classic Release Pipelines or Deployment Jobs in multi-stage YAML Pipelines? According to the docs it should work for the latter:

Caching is currently supported in CI and deployment jobs, but not classic release jobs.

The issue persists Tried with a macOS agent with a deployment in a multi staged yaml