0
votes

I m trying to create build pipeline on azure devops server, my build pipeline is able to download dependences from Azure Artifact

2021-03-02T05:45:24.8329366Z [INFO] ------------------------------------------------------------------------
2021-03-02T05:45:24.8329608Z [INFO] Total time:  02:31 min
2021-03-02T05:45:24.8330187Z [INFO] Finished at: 2021-03-02T05:45:24Z
2021-03-02T05:45:24.8330469Z [INFO] ------------------------------------------------------------------------
2021-03-02T05:45:24.8330824Z [ERROR] Failed to execute goal on project myapplication-commons-lib: Could not resolve dependencies for project com.myapplication.mdm.commons:myapplication-commons-lib:jar:1.0.0-SNAPSHOT: Failed to collect dependencies at com.tibco.ebx.core:ebx-lib:jar:5.9.10: Failed to read artifact descriptor for com.tibco.ebx.core:ebx-lib:jar:5.9.10: Could not transfer artifact com.tibco.ebx.core:ebx-lib:pom:5.9.10 from/to myapp-snapshots (https://myapplication.pkgs.visualstudio.com/_packaging/myapp-snapshots/maven/v1): Authentication failed for https://myapplication.pkgs.visualstudio.com/_packaging/myapp-snapshots/maven/v1/com/tibco/ebx/core/ebx-lib/5.9.10/ebx-lib-5.9.10.pom 401 Unauthorized -> [Help 1]
2021-03-02T05:45:24.8331113Z [ERROR] ```


YAML Pipeline
[![enter image description here][1]][1]


[![enter image description here][2]][2]


  [1]: https://i.stack.imgur.com/L34oP.png

YAML from pipeline 

- task: Maven@3
  displayName: 'Code Compilation'
  inputs:
    mavenPomFile: '$(System.DefaultWorkingDirectory)/solution/core/build/maven/pom.xml'
    options: '-s $(System.DefaultWorkingDirectory)/solution/core/build/maven/settings.xml'
    goals: package
    mavenAuthenticateFeed: true    
1
You are not allowed (m 401 Unauthorized - to access the given repository)... myworld.pkgs.visualstudio.com ???khmarbaise
ohk what can be done to resolve thisSatyam Pandey

1 Answers

0
votes

....401 Unauthorized

The 401 error is an authentication error.

Add the Maven Authenticate task before calling Maven task. The Maven Authenticate task can provide credentials for Azure Artifacts feeds and external Maven repositories in the current user's settings.xml file.

enter image description here

If your azure artifacts are in the same Collection, you can directly select the corresponding feed in drop down list.

If yours is external azure artifacts(e.g. Azure Devops Service), you need to create a service connection(maven) in Porject Settings -> Service Connections.

enter image description here

Update:

If you couldn't use Maven Authenticate task, you could try the following steps to use the Settings.xml file.

Step1: Create a Setting.xml file.

You could navigate to Azure Devops Service -> Artifacts -> Connect to feed -> Maven.

enter image description here

Step2: In you Azure Devops Server, you could save your settings.xml to the path

%USERPROFILE%\.m2\settings.xml

You could refer to this doc.

On the other hand, when you add option to the Maven task.

For example:

- task: Maven@3
  displayName: 'Maven pom.xml'
  inputs:
   ...
    options: '-s filepath/settings.xml'