本文介绍了上传和下载天蓝色工件的等效maven命令和设置是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Maven项目(在管道中),该项目需要使用在另一个Azure管道中(通过mvn deploy)部署的工件作为依赖项.

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

我能够使用以下命令行将工件上传和下载到Azure devops:

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 .

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 .

等效的maven命令应类似于:

For which the equivalent maven commands should be something like:

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

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

我的maven-azuredevops-settings.xml中的位置:

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>

类似地,我在pom.xml中具有建议在Azure上使用的设置-尽管我没有完全掌握它们.

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

但是我发现一些差异.当maven在管道中部署程序包时,在提要中查看时,工件前面有一个大的M.它也被列为:

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

如果直接用az artifacts上传,则它是普通的通用软件包,而不是maven软件包.一个关键的区别(是否是唯一的区别?)是同一工件中也存在.pom工件.我的Maven构建会创建此文件并将其放置在本地存储库中,但我不清楚如何将其作为同一工件的一部分而不是Feed中的单独文件发布.

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.

我也遇到了项目范围的提要(例如--scope和--project)的麻烦. Maven报告401未经授权,而不是说缺少软件包.如果我尽管登录但仍从命令行获取回购的URL,则会得到401.这是我目前的主要问题.

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.

很明显,在我对Azure和Maven的理解上存在一些空白,这是我的新手.有人可以启发我如何使maven命令正常工作,或者在可能的情况下使azure命令具有同等的行为.

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.

对于上下文,我试图通过脱机执行等效命令来调试管道.另请参见 Azure DevOps管道-Maven部署仅在不存在的情况下释放

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

推荐答案

首先,对于通用软件包,它只是您已上传到我们的服务并标有名称和版本的文件的集合.您可以通过在构建或发布过程中的通用软件包"任务.

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.

更多信息,您可以参考:开始使用Universal包裹

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

由于您使用的是JAVA软件包,请通过MVN部署来部署/发布JAVA软件包.

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

第二,有收集和项目级别/范围的提要.对于项目级别/范围,您需要在URL中指定项目名称,例如 https://pkgs.dev.azure.com/{org}/{project}/_packaging/{feed}/maven/v1 .

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.

第三,要在另一个JAVA项目中使用JAVA软件包,您需要在用户文件夹($ {user.home}/.m2)的settings.xml中配置凭据.对于构建或发布管道,您只需添加进行身份验证的Maven身份验证任务.

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.

然后,您需要在pom.xml中指定包(在部分中).您可以在连接到供稿>"中获取此信息.选择Maven.

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

更多信息,您可以参考:开始使用Maven提要和工件

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

这篇关于上传和下载天蓝色工件的等效maven命令和设置是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 15:58