Search code examples
mavenazure-devopsmaven-toolchains-plugin

specified user toolchains file does not exist


I am trying to run a test on one of the pools present and while doing do I am getting the below error

Apache Maven 3.3.9
Maven home: /usr/share/maven
Java version: 1.8.0_282, vendor: Private Build
Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en_US, platform encoding: ANSI_X3.4-1968
OS name: "linux", version: "3.10.0-1127.13.1.el7.x86_64", arch: "amd64", family: "unix"
/usr/bin/mvn -f /azp/_work/81/s/pom.xml -tags=@FmaTest clean test
[ERROR] Error executing Maven.
[ERROR] The specified user toolchains file does not exist: /azp/_work/81/s/ags=@Test

tried with a couple of options that I found online but all in vain


Solution

  • The specified user toolchains file does not exist:

    Based on the error info, the cause of this issue is that the toolchains.xml hasn't been added to the $HOME/.m2 folder.

    You can try to check the $Home in Pipeline with the following script:

    steps:
      - script: echo $HOME 
    

    Then you can use the Copy File task to copy the toolchains.xml to the target folder.

    For example: the $Home : /home/vsts

    - task: CopyFiles@2
      displayName: 'Copy Files to: /home/vsts/.m2'
      inputs:
        SourceFolder: '$(build.sourcesdirectory)'
        Contents: toolchains.xml
        TargetFolder: /home/vsts/.m2
    

    In this case, I can run the maven task successfully.

    Here is the doc about using the toolchains

    This file should be put in your ${user.home}/.m2 directory.