Azure CLI:从容器内下载管道运行工件

问题描述 投票:0回答:1

根据文档,可以使用以下语法来下载管道工件:

az pipelines runs artifact download --organization <organization> --project <project> --run-id <run-id> --artifact-name <artifact-name> --path .

问题是我们所有的工件都在容器和子容器内。

如果我填写所有值,并将容器指定为 ,我会收到一条错误消息,指出已找到工件,但它是一个容器。据我了解,不支持下载整个容器。

但我想获取单个文件:container/sub-container/filename.json。

如果我如上所述使用斜杠或反斜杠指定工件名称,则表示找不到该工件。

那么,如何下载容器中包含的文件呢?

azure-devops azure-pipelines azure-cli
1个回答
0
投票

根据这个官方MS文档

az pipelines runs artifact download --artifact-name

包含指定整个工件名称的参数,而不是指定文件夹或子文件夹的路径。作为一种解决方法,您可以在一个路径中下载整个工件,然后将特定文件复制到所需位置,如下所示:-

复制整个工件:-

az pipelines runs artifact download --organization https://dev.azure.com/Orgname --project projectname --run-id runid --artifact-name drop --path pathtodownloadtheartifact

enter image description here

将特定文件复制到下载的工件的路径中,如下所示:-

选项:-

# Download the artifact
az pipelines runs artifact download --artifact-name Artifactname --path /path/to/download/location --run-id runID

download_path="/path/to/download/location/MyArtifact" #Downloaded artifact path
destination_path="/path/to/destination" #Another path to copy specific file

#Create another path dir if it does not exist
mkdir -p "$destination_path"

# Copy all .txt files to another destination path
cp "$download_path"/*.txt "$destination_path"
© www.soinside.com 2019 - 2024. All rights reserved.