microsoft / azure-pipelines-artifact-caching-tasks

Azure Pipelines Tasks to cache intermediate artifacts from build (e.g. resolved node packages)
MIT License
50 stars 15 forks source link

Save artifact skipped after npm install #34

Open Grompie opened 4 years ago

Grompie commented 4 years ago

My pipeline runs on a hosted agent and it's not a forked repository. But after the npm install step or npm build step (tried both) the save artifact is always skipped. (Same if I use the combined restore and save task)

Step yaml:

steps:
- task: 1ESLighthouseEng.PipelineArtifactCaching.SaveCacheV1.SaveCache@1
  displayName: 'Save artifact based on: **/package-lock.json, !**/node_modules/**/package-lock.json, !**/.*/**/package-lock.json'
  inputs:
    keyfile: '**/package-lock.json, !**/node_modules/**/package-lock.json, !**/.*/**/package-lock.json'
    targetfolder: '**/node_modules, !**/node_modules/**/node_modules'
    vstsFeed: 'b43b132c-7213-4f99-86be-e365f9b81320'

I enabled system diagnostics see more in the log this is what it's saying at the end: (log is to long to post fully here)

2020-02-19T13:21:40.6619967Z ##[debug]121098 results 2020-02-19T13:21:40.6620193Z ##[debug]found 121098 paths 2020-02-19T13:21:40.6620368Z ##[debug]applying include pattern 2020-02-19T13:21:41.7090069Z ##[debug]306 matches 2020-02-19T13:21:41.7095332Z ##[debug]pattern: '!\node_modules\\node_modules' 2020-02-19T13:21:41.7095502Z ##[debug]trimmed leading '!'. pattern: '\node_modules\\node_modules' 2020-02-19T13:21:41.7095696Z ##[debug]after ensurePatternRooted, pattern: 'd:\a\1\s*\node_modules*\node_modules' 2020-02-19T13:21:41.7095810Z ##[debug]applying exclude pattern 2020-02-19T13:21:41.7146928Z ##[debug]305 matches 2020-02-19T13:21:41.7151200Z ##[debug]1 final results 2020-02-19T13:21:41.7156704Z ##[debug]


2020-02-19T13:21:41.7156947Z ##[debug]Found target folder: src\clients\workspace\node_modules 2020-02-19T13:21:41.7157360Z ##[debug]-----------------------------

2020-02-19T13:21:41.7184265Z ##[debug]Absolute path for pathSegments: d:\a\1\s\src\clients\workspace\libs\ngx-app-settings\package-lock.json = d:\a\1\s\src\clients\workspace\libs\ngx-app-settings\package-lock.json 2020-02-19T13:21:41.7184611Z ##[debug]Absolute path for pathSegments: d:\a\1\s\src\clients\workspace\package-lock.json = d:\a\1\s\src\clients\workspace\package-lock.json 2020-02-19T13:21:41.7269669Z ##[debug]platformIndependent=false 2020-02-19T13:21:41.8275658Z ##[debug]win32-0a4407a3b3b2b8eda3115a3700c0aa1c2d3e09263cfaf8d2e7d2770566e809fe=undefined 2020-02-19T13:21:41.8276529Z ##[debug]task result: Skipped 2020-02-19T13:21:41.8304250Z ##[debug]Processed: ##vso[task.complete result=Skipped;]Not caching artifact produced during build: win32-0a4407a3b3b2b8eda3115a3700c0aa1c2d3e09263cfaf8d2e7d2770566e809fe 2020-02-19T13:21:42.6530188Z ##[section]Finishing: Save artifact based on: /package-lock.json, !/node_modules//package-lock.json, !/.*/**/package-lock.json

Any idea what the problem is here? I just can't figure it out what I'm doing wrong.

ethanis commented 4 years ago

This typically happens if the contents of the keyFile changes between the restore and save steps. For npm, this most often happens as a result of running npm ci which will change the contents of package-lock.json before resolving packages (see #16).

If that's not the issue, can you share your full build script and email me verbose build logs (etdenn at microsoft com)?

manandkumaar commented 4 years ago

@ethanis I have tried all the suggestions mentioned in #16 but still Post-job: Cache npm is getting skipped.

I am following the NX recommended distributed CI in my project. https://github.com/nrwl/nx-azure-build/blob/master/.azure-pipelines/steps/install-node-modules.yml

Your help and support is greatly appreciated.

Environment : Pool: Azure Pipelines Image: ubuntu-latest Agent: Azure Pipelines 2

install-node-modules.yml

steps:
  - task: NodeTool@0
    inputs:
      versionSpec: '10.x'
    displayName: 'Install Node.js'
  - task: 1ESLighthouseEng.PipelineArtifactCaching.RestoreAndSaveCacheV1.RestoreAndSaveCache@1
    inputs:
      keyfile: '**/package-lock.json, !**/node_modules/**/package-lock.json, !**/.*/**/package-lock.json'
      targetfolder: '**/node_modules, !**/node_modules/**/node_modules'
      vstsFeed: 'Terra-NPM'
  - script: |
      npm ci
    displayName: Install dependencies only if there is no cache available
    condition: ne(variables['CacheRestored'], 'true')

This is the error i have found from logs :-

##[warning]Error: An unexpected error occurred while trying to download the package. Exit code(19) and error({"@t":"2020-07-17T07:46:53.3020695Z","@m":"Ignoring --cache-directory because the cache is not yet supported on OS \"Linux 5.3.0-1032-azure #33~18.04.1-Ubuntu SMP Fri Jun 26 15:01:15 UTC 2020\".","@i":"c2cd87c0","@l":"Warning","SourceContext":"ArtifactTool.Commands.UPackDownloadCommand","UtcTimestamp":"2020-07-17 07:46:53.302Z"}

Screenshot :- image

msreekm commented 4 years ago

haev the same issue -Ignoring --cache-directory because the cache is not yet supported on OS \"Linux 5.3.0-1032-azure #33~18.04.1-Ubuntu

tengoal commented 4 years ago

Same:

##[warning]Error: An unexpected error occurred while trying to download the package. Exit code(19) and error({"@t":"2020-07-26T22:26:03.3426127Z","@m":"Ignoring --cache-directory because the cache is not yet supported on OS \"Linux 5.3.0-1032-azure #33~18.04.1-Ubuntu SMP Fri Jun 26 15:01:15 UTC 2020\".","@i":"c2cd87c0","@l":"Warning","SourceContext":"ArtifactTool.Commands.UPackDownloadCommand","UtcTimestamp":"2020-07-26 22:26:03.342Z"}

cee-money commented 3 years ago

Any update on this issue? I'm encountering the identical error.