【问题标题】:Associate build artifact to Nexus repo将构建工件与 Nexus 存储库相关联
【发布时间】:2020-10-16 10:38:56
【问题描述】:

https://docs.microsoft.com/en-us/azure/devops/pipelines/scripts/logging-commands?view=azure-devops&tabs=bash

我在 PowerShell 中创建了一个自定义 Nexus 上传脚本,以将构建工件从工件暂存目录上传到 Nexus 存储库。在 PS 脚本中,我正在运行以下命令,因此构建管道与 Nexus 存储库中的工件相关联。但是我不确定应该为 artifacttype 放什么,根据文档,选项似乎是 container|filepath|versioncontrol|gitref|tfvclabel。

Write-Host "##vso[artifact.associate artifacttype=filepath;artifactname=$fileName]http://nexusDNS:8081/repository/$Repository"

无论如何,在将构建管道与发布管道关联后,我运行了一个发布,它最初会尝试下载链接的工件,这就是我得到的消息。

从 http:\nexusDNS:8081\repository\Test\Testartifact.zip 下载工件 Testartifact.zip

因为我将 artifacttype 声明为“文件路径”,所以它会将 http:// 转换为 http:。

有人可以帮助我如何制作发布管道以直接从 Nexus 下载工件吗?作为发布任务的一部分,我是否必须编写另一个脚本才能使用 Nexus API 下载工件?

【问题讨论】:

    标签: azure-devops nexus azure-devops-extensions


    【解决方案1】:

    您可以尝试Sonatype Nexus Repository Release Artifact 扩展。此扩展在利用 Release Pipelines 时为 Nexus Maven Repositories 提供支持,初始版本包括对 Nexus Maven Repositories 的 Release Pipeline Artifact 支持,以及提供用于从 Maven Repositories 下载资产的 Azure Pipelines 任务。

    此扩展程序要求您首先配置服务连接以连接到您的 Nexus 存储库服务器 (project settings -> Services Connections tab and create a New Service Connection of type Sonatype Nexus Repository)。连接后,您可以链接来自 Nexus Maven 存储库的源工件并在发布管道中使用这些工件。

    此外,您还可以使用 REST API 从 nexus repo 下载工件。详情请参考此ticket

    wget "http://local:8081/service/local/artifact/maven/redirect?g=com.mycompany&a=my-app&v=LATEST" --content-disposition
    

    【讨论】:

    猜你喜欢
    • 2018-09-12
    • 2012-01-15
    • 2015-02-13
    • 2012-05-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-04
    • 2022-01-23
    相关资源
    最近更新 更多