azure-pipelines-tasks: CacheBeta task: "The path provided is invalid" for Maven repository

Required Information

Question, Bug, or Feature?
Type: Question

Enter Task Name: CacheBeta@0

I’m trying to use the cache in a Maven project. These are the relevant parts of the azure-pipelines.yml file:

variables:
  MAVEN_CACHE_FOLDER: /home/user/.m2/repository
  MAVEN_OPTS: '-Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)'

resources:
  containers:
  - container: flink-build-container
    image: rmetzger/flink-ci:latest

jobs:
- job: main
  steps:
  - task: CacheBeta@0
    inputs:
      key: maven | **/pom.xml
      path: /home/user/.m2/repository
    displayName: Cache Maven local repo
  - task: Maven@3
   ...

I’m getting the following unexpected error:

##[error]The path provided is invalid.

This is a build with that error: https://dev.azure.com/rmetzger/Flink/_build/results?buildId=86&view=logs&j=a6fe42f4-2b81-59e8-5c7c-1a0db487583c This is the full azure-pipelines.yml file from that build: https://github.com/rmetzger/flink/blob/3d201d6abd020adad68e3bc842b4c4b7e0d3d260/azure-pipelines.yml

I have put the path directly, instead of using the variable as suggested in the documentation to rule out any issues with the variable system.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 30 (10 by maintainers)

Most upvoted comments

In my case the issue could be solved. I was wrongly assuming that MAVEN_OPTS will always be picked up by the maven execution. It turned out this is not the case so I had to pass this explicitly to the options in my pipeline:

- task: Maven@3
  inputs:
      ...
      options: '$(MAVEN_OPTS)'
     ...

After this, the documented configuration works.

I was wrongly assuming that MAVEN_OPTS will always be picked up by the maven execution. It turned out this is not the case so I had to pass this explicitly to the options in my pipeline:

(from https://github.com/microsoft/azure-pipelines-tasks/issues/11259#issuecomment-535938080)

This behavior is now at least documented: https://github.com/MicrosoftDocs/azure-devops-docs/pull/8142 (though I would prefer to have the Maven task respect the global variable)

Thanks for your comments. @johnterickson The container download time is really not a concern for us at the moment. But I’ll still keep an eye on this.

@aasim: After I commented here, I had the same thought and I found the PublishTestResults@2 task. I will investigate this soon (I consider it a nice to have task) I don’t think I need the MavenAuthenticate@0 task, as we are are only relying on public dependencies.

I have also seen that the cache doesn’t keep the correct mode of the file so some file that are executable lost their mod …

@gpad That is rolling out per #10925

@danielwertheim and @ifiokjr - could you file separate issues for problems you are seeing with yarn/npm/dotnet/nuget? I don’t want those to be lost in this Maven discussion.