jasonroy7dct
jasonroy7dct

Reputation: 47

Azure DevOps manually publish an external libraries to Azure Artifacts?

When I run my build pipeline, all the libraries will publish to the Azure DevOps Artifacts(Because they will downloaded in Maven Central).

But I have a external libraries which I have created manually on my local computer and it's a jar like this picture.external libraries jar

I want to add this jar to Azure DevOps Artifacts so that when next time I run my pipeline, it can access to my external libraries jar.

How can I do it? I have tried this solution. But it cannot work.

az artifacts universal publish --organization https://dev.azure.com/example/ --feed my_feed --name my-artifact-name --version 0.0.1 --description "Test Description" --path this solution

Upvotes: 2

Views: 9664

Answers (2)

Cleber Muramoto
Cleber Muramoto

Reputation: 51

Artifacts deployed with universal publish can't be read by maven projects, which makes them useless outside Azure Pipelines.

To deploy your libs or external jars to azure you should configure your settings.xml as per feed instructions, e.g.,

  <servers>
    <server>
      <id>FeedId</id>
      <username>user</username>
      <password>token</password>
    </server>
  </servers>

And then use a deploy-file goal

mvn org.apache.maven.plugins:maven-deploy-plugin:2.4:deploy-file -Dpackaging=jar -DrepositoryId=FeedId -Durl=https://pkgs.dev.azure.com/<org>/_packaging/FeedId/maven/v1 -DgroupId=my.group.id -DartifactId=artifactId -Dversion=1.0 -Dfile=<path_to_local.jar> -DpomFile=<path_to_local.pom>

Make sure to use 2.4 version if the file already resides in your local repo (~/.m2/repository/my/group/id/artifactId). Since version 2.5+ the deploy plugin will fail to deploy jars already present in the local repo.

Upvotes: 3

Walter
Walter

Reputation: 3058

You can refer to the document about az artifacts universal publish. Here is my sample:

1.Log into Azure DevOps:

az login

or

az devops login --organization https://dev.azure.com/{Organization}/

2.Publish packages:

My file is in the C:\sample folder:

enter image description here

Here is my command:

az artifacts universal publish --organization https://dev.azure.com/{Organization}/ --feed {Feed name} --name sample.jar --version 0.0.1 --description "Welcome to Universal Packages" --path C:\sample\sample.jar.

enter image description here In addition, it is Organization scoped feeds.

enter image description here

If you are publishing packages to Project scoped feeds, please also add project name in your command:

az artifacts universal publish --organization https://dev.azure.com/{Organization}/ --project="{Project}" --scope project --feed {Feed name} --name my-first-package --version 0.0.1 --description "Welcome to Universal Packages" --path .

Upvotes: 0

Related Questions