2

I have a maven project (in a pipeline) that needs to consume artifacts deployed (via mvn deploy) in another azure pipeline as a dependency.

I am able to upload and download artifacts to Azure devops using command lines like:

az artifacts universal publish \
    --organization https://myorg.visualstudio.com \
    --scope project \
    --project="myproject" \
    --feed myfeed \
    --name someartifact-1.99.1.jar \
    --version 1.99.1 \
    --description "snafu" \
    --debug \
    --path .

and

az artifacts universal download
   --organization "https://myorg.visualstudio.com/"
   --project "myproject"
   --scope project
   --feed "myfeed"   
   --name "someartifact-1.99.1.jar"   --version "1.99.1"
   --path .

For which the equivalent maven commands should be something like:

mvn deploy:deploy-file -DWHERE="AzureDevops" clean deploy

and

mvn -X -B -s maven-azuredevops-settings.xml 
 -DWHERE=AzureDevops
 -DrepoURL=https://myorg.pkgs.visualstudio.com/myproject/_packaging/myfeed/maven/v1   
 dependency:get 
 -Dartifact=com.foobar.blah:someartifact:1.99.1
 -Ddest=./clientartifact.jar

Where I have in my maven-azuredevops-settings.xml:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                              https://maven.apache.org/xsd/settings-1.0.0.xsd">
  <interactiveMode>false</interactiveMode>
  <servers>
    <server>
      <id>feedname</id>
      <username>azureusername</username>
      <password>personal access token</password>
    </server>
  </servers> 
</settings>

Likewise, I have the settings recommended on Azure in the pom.xml - though I don't fully grok them.

However I notice some differences. When a package is deployed by maven in a pipeline the Artifact has a big M for maven in front of it when viewed in the feed. It is also listed as:

com.foobar.blah:someartifact 1.9.9

If uploaded with az artifacts directly it is a plain universal package not a maven package. A key difference (is it the only one?) is that there is a .pom artifact as well in the same artifact. My maven build creates this and puts it in the local repository but I am not clear how to publish it as part of the same artifact rather than a separate file in the feed.

I also have trouble with project scoped feeds (i.e. with --scope and --project). Maven reports the 401 unauthorized rather than saying a package is missing. I get a 401 if I wget the URL of the repo from command line despite being logged in. This is my main issue at present.

Clearly there are some gaps in my understanding of both Azure and Maven both of which I am new to. Can someone enlighten me as to how to get the maven commands to work properly or alternatively make the azure commands behave equivalently where that is possible.

For context I am trying to debug a pipeline by executing the equivalent commands offline. See also Azure DevOps Pipeline - Maven deploy release only if it does not exist

Bruce Adams
  • 4,953
  • 4
  • 48
  • 111
  • az artifacts command is from universal package. You should use mvn command for maven packages. What was problem you encountered when using mvn commands? – Levi Lu-MSFT Jul 01 '20 at 10:12

1 Answers1

0

Firstly, for Universal package, it is just a collection of files that you’ve uploaded to our service and labelled with a name and version. And you can download it through Universal Package task during build or release.

More information, you can refer to: Getting started with Universal Packages

Since you are using JAVA package, please deploy/publish JAVA package through MVN deploy.

Secondly, there are collection and project level/scope feeds. For project level/scope, you need to specify project name in URL, such as https://pkgs.dev.azure.com/{org}/{project}/_packaging/{feed}/maven/v1.

Thirdly, to use JAVA package in another JAVA project, you need to configure credential in settings.xml in user's folder (${user.home}/.m2). For build or release pipeline, you just need to add Maven Authenticate task for authentication.

Then, you need to specify package in pom.xml (under section). You could get this information in Connect to feed > select Maven.

More information, you can refer to: Get started with Maven feeds and Artifacts

starian chen-MSFT
  • 33,174
  • 2
  • 29
  • 53