Azure工件-下载特定版本的Maven工件 [英] Azure Artifacts - Download a specific version of maven artifact
问题描述
我们在CI/CD流程中使用了天蓝色devops.很多时候,为了进行一些自定义构建,我们需要从工件存储库中下载特定的Maven jar.
是否有一种方法(命令行或API)来执行相同的操作?
同样的问题是关于从天蓝色文物下载特定的jar.
Azure神器-下载特定版本的Maven神器
答案是肯定的.我们可以使用REST API
现在,我们有了所有参数, feedId
, groupId
, artifactId
, version
,fileName
.
因此,我们可以将REST API与 -OutFile $(Build.SourcesDirectory)\ myFirstApp-1.0-20190818.032400-1.jar
一起使用以下载软件包(内联powershell任务):
$ url =" https://pkgs.dev.azure.com/< OrganizationName>/_apis/packaging/feeds/83cd6431-16cc-480d-bb4d-a213e17b3a2b/maven/MyGroup/myFirstApp/1.0-SNAPSHOT/myFirstApp-1.0-20190818.032400-1.jar/content?api-version = 5.1-preview.1$ buildPipeline =调用静态方法-Uri $ url -OutFile $ {Build.SourcesDirectory)\ myFirstApp-1.0-20190818.032400-1.jar-标头@ {授权=承载者$ env:SYSTEM_ACCESSTOKEN";方法获取
由于我的Maven Feed是组织范围的Feed,因此我从URL中省略了项目参数.
结果:
We are using azure devops for our CI/CD process. Many a times, in order to do some custom builds, we need to download the specific maven jar from artifact repo.
Is there a way (commandline or API) to do the same ?
Again the question is about download specific jar from azure artifacts.
Azure Artifacts - Download a specific version of maven artifact
The answer is yes. We could use the REST API Maven - Download Package to download the specific jar from azure artifacts:
GET https://pkgs.dev.azure.com/{organization}/{project}/_apis/packaging/feeds/{feedId}/maven/{groupId}/{artifactId}/{version}/{fileName}/content?api-version=5.1-preview.1
First, we need to get the feedId
. We could use the REST API Feed Management - Get Feeds to get the feedId
:
GET https://feeds.dev.azure.com/{organization}/{project}/_apis/packaging/feeds?api-version=5.1-preview.1
Note: The project parameter must be supplied if the feed was created in a project. If the feed is not associated with any project, omit the project parameter from the request.
For other parameters in the URL, we could get it from the overview of the package. Select the package and open the package, we could get following view:
Now, we have all the parameters, feedId
, groupId
, artifactId
, version
, fileName
.
So, we could use the REST API with -OutFile $(Build.SourcesDirectory)\myFirstApp-1.0-20190818.032400-1.jar
to download the package (Inline powershell task):
$url = "https://pkgs.dev.azure.com/<OrganizationName>/_apis/packaging/feeds/83cd6431-16cc-480d-bb4d-a213e17b3a2b/maven/MyGroup/myFirstApp/1.0-SNAPSHOT/myFirstApp-1.0-20190818.032400-1.jar/content?api-version=5.1-preview.1"
$buildPipeline= Invoke-RestMethod -Uri $url -OutFile $(Build.SourcesDirectory)\myFirstApp-1.0-20190818.032400-1.jar -Headers @{
Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"
} -Method Get
Since my maven feed is an organization scoped feed, I omit the project parameter from the URL.
The result:
这篇关于Azure工件-下载特定版本的Maven工件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!