diff --git a/package-lock.json b/package-lock.json index 601383c..3d53cd3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "azure-pipelines-tool-lib", - "version": "1.1.0", + "version": "1.2.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 4375a4f..9a33321 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "azure-pipelines-tool-lib", - "version": "1.1.0", + "version": "1.2.0", "description": "Azure Pipelines Tool Installer Lib for CI/CD Tasks", "main": "tool.js", "scripts": { diff --git a/tool.ts b/tool.ts index d4619c2..1923d36 100644 --- a/tool.ts +++ b/tool.ts @@ -194,11 +194,17 @@ export function findLocalToolVersions(toolName: string, arch?: string) { /** * Download a tool from an url and stream it into a file * - * @param url url of tool to download - * @param fileName optional fileName. Should typically not use (will be a guid for reliability). Can pass fileName with an absolute path. - * @param handlers optional handlers array. Auth handlers to pass to the HttpClient for the tool download. + * @param url url of tool to download + * @param fileName optional fileName. Should typically not use (will be a guid for reliability). Can pass fileName with an absolute path. + * @param handlers optional handlers array. Auth handlers to pass to the HttpClient for the tool download. + * @param additionalHeaders optional custom HTTP headers. This is passed to the REST client that downloads the tool. */ -export async function downloadTool(url: string, fileName?: string, handlers?: ifm.IRequestHandler[]): Promise { +export async function downloadTool( + url: string, + fileName?: string, + handlers?: ifm.IRequestHandler[], + additionalHeaders?: ifm.IHeaders +): Promise { return new Promise(async (resolve, reject) => { try { handlers = handlers || null; @@ -226,9 +232,9 @@ export async function downloadTool(url: string, fileName?: string, handlers?: if if (fs.existsSync(destPath)) { throw new Error("Destination file path already exists"); } - + tl.debug('downloading'); - let response: httpm.HttpClientResponse = await http.get(url); + let response: httpm.HttpClientResponse = await http.get(url, additionalHeaders); if (response.message.statusCode != 200) { let err: Error = new Error('Unexpected HTTP response: ' + response.message.statusCode);