Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getArtifactContentZip doesn't work for "resource.type": "PipelineArtifact" #432

Open
kiermasp opened this issue Mar 3, 2021 · 16 comments
Open

Comments

@kiermasp
Copy link

kiermasp commented Mar 3, 2021

Environment

Node version: 14.15.5
Npm version: 6.14.11
OS and version: Microsoft Windows 10 Enterprise, Version 10.0.18363 Build 18363
azure-devops-node-api version: 10.2.1

Issue Description

IBuildApi.getArtifactContentZip does't work for artifact resource type: PipelineArtifact but it does for type: Container

Expected behaviour

I should be able to get zip from Build Artifacts and Pipeline Artifacts

Actual behaviour

In fiddler I'm getting 404 where the same url working correctly on Web using "Get Artifact URL and pasting to Browser".

Steps to reproduce

  1. IBuildApi.getArtifacts - ensure on list you have artifacts with "resource.type": "PipelineArtifact"
  2. try to fetch it using IBuildApi.getArtifactContentZip()
  3. Fiddler shows 404 and unable to get it.

Logs

REQ
GET https://artprodsu6weu.artifacts.visualstudio.com/Ad2f735ff-1e43-4ce8-826b-9e3578951332/2a4e21b6-7b9c-47c3-9a4f-0430e7a2fec9/_apis/artifact/XXXXXXXXXXXXXXXXXXXX/content?format=zip HTTP/1.1
accept: application/zip;api-version=6.1-preview.5
user-agent: node-Build-api
Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X-TFS-FedAuthRedirect: Suppress
Host: artprodsu6weu.artifacts.visualstudio.com
Connection: close

RESP
HTTP/1.1 404 Not Found
P3P: CP="CAO DSP COR ADMa DEV CONo TELo CUR PSA PSD TAI IVDo OUR SAMi BUS DEM NAV STA UNI COM INT PHY ONL FIN PUR LOC CNT"

@github-actions
Copy link

This issue has had no activity in 90 days. Please comment if it is not actually stale

@linsword13
Copy link

Should this be re-opened given that this is still an existing issue?

The sample code seems to indicate this is a known limitation. This is unfortunate especially since PublishBuildArtifacts ado task is considered deprecated and pipeline artifact is recommended instead.

Thanks.

@anatolybolshakov
Copy link
Contributor

Hi @linsword13 reopening this since it's still actual.

@github-actions
Copy link

This issue has had no activity in 90 days. Please comment if it is not actually stale

@github-actions github-actions bot added the stale label Dec 28, 2021
@kiermasp
Copy link
Author

Still actual

@github-actions github-actions bot removed the stale label Dec 28, 2021
@github-actions
Copy link

This issue has had no activity in 90 days. Please comment if it is not actually stale

@arturbosch
Copy link

Still actual

@linsword13
Copy link

linsword13 commented Apr 9, 2022

I currently use something like the following as a workaround (requires an extra roundtrip unfortunately):

const buildApi = this.adoWebApi.getBuildApi();
const artifact = await buildApi.getArtifact(projectName, buildId, artifactName);
if (!artifact) {
    throw new Error('...');
}
if (!artifact.resource?.downloadUrl) {
    throw new Error('...');
}
const stream = (await buildApi.http.get(artifact.resource.downloadUrl)).message;
const jsZip = (await unzip(stream)).folder(artifactName);

@arturbosch
Copy link

I currently use something like the following as a workaround (requires an extra roundtrip unfortunately):

const buildApi = this.adoWebApi.getBuildApi();
const artifact = await buildApi.getArtifact(projectName, buildId, artifactName);
if (!artifact) {
    throw new Error('...');
}
if (!artifact.resource?.downloadUrl) {
    throw new Error('...');
}
const stream = (await buildApi.http.get(artifact.resource.downloadUrl)).message;
const jsZip = (await unzip(stream)).folder(artifactName);

Thanks for the workaround!
Can confirm that it works.

@50Wliu
Copy link
Member

50Wliu commented Apr 19, 2023

@anatolybolshakov this is still broken (using azure-devops-node-api@11.2.0, doesn't look like BuildApi changed in 12.0.0).
Can we please reopen this and keep it open until it's fixed rather than having to fight with the stale bot every 3 months?

It's the same root cause as microsoft/azure-devops-extension-api#48 - 7.1-preview.5 isn't accepted as an API version. Changing to 7.0-preview (or omitting the api-version header entirely) works.

@50Wliu
Copy link
Member

50Wliu commented May 2, 2023

@anatolybolshakov @max-zaytsev more pings to reopen this issue.

Our current workaround is:

// 🚨 HACK TIME 🚨
// ADO's APIs try to download pipeline artifacts using an API version that isn't supported
// by the artifact download endpoint.
// One way of getting around that is by temporarily removing the API version to force it to use
// a supported version. Woo!
// https://github.com/microsoft/azure-devops-node-api/issues/432
const buildApi: BuildApi = await connection.getBuildApi();

const originalCreateAcceptHeader = buildApi.createAcceptHeader;
buildApi.createAcceptHeader = (type: string): string => type;

const download = await buildApi.getArtifactContentZip(project, buildId, artifactName);

buildApi.createAcceptHeader = originalCreateAcceptHeader;

which avoids the extra roundtrip in the other workaround.

@johnterickson johnterickson reopened this Nov 2, 2023
@johnterickson
Copy link

Folks are still hitting this.

@github-actions github-actions bot removed the stale label Nov 2, 2023
Copy link

This issue has had no activity in 90 days. Please comment if it is not actually stale

@github-actions github-actions bot added the stale label Jan 31, 2024
@50Wliu
Copy link
Member

50Wliu commented Feb 5, 2024

I don't see any relevant commits here, so I'm going to go out on a limb and say that this is still broken.

Copy link

github-actions bot commented May 5, 2024

This issue has had no activity in 90 days. Please comment if it is not actually stale

@github-actions github-actions bot added the stale label May 5, 2024
@50Wliu
Copy link
Member

50Wliu commented May 7, 2024

Yep, still broken.

@github-actions github-actions bot removed the stale label May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants