@@ -4,23 +4,7 @@ import { platform, arch } from 'os';
44import * as taskLib from 'azure-pipelines-task-lib/task' ;
55import * as toolLib from 'azure-pipelines-tool-lib/tool' ;
66import { ClientRequest } from 'http' ;
7- import axios , { AxiosError } from 'axios' ;
8- import axiosRetry from 'axios-retry' ;
9-
10- axiosRetry ( axios ,
11- {
12- retries : 3 ,
13- retryCondition : ( error : AxiosError ) => {
14- if ( ! error . response || error . response . status >= 400 ) {
15- if ( error . response ) {
16- taskLib . debug ( `Retrying request with status code '${ error . response . status } '.` ) ;
17- taskLib . debug ( `Response received: '${ JSON . stringify ( error . response ) } '.` ) ;
18- }
19- return true ;
20- }
21- return false ;
22- }
23- } ) ;
7+ import axios from 'axios' ;
248
259export function getDownloadUrl ( version : string ) : string {
2610 const agentPlatform = platform ( ) ;
@@ -51,13 +35,9 @@ export function getDownloadUrl(version: string): string {
5135
5236export async function getLatestVersionTag ( ) : Promise < string > {
5337 return await axios
54- . get ( 'https://api.github.com/repos/Azure/Bicep/releases/latest' , {
55- headers : {
56- 'User-Agent' : 'piraces' ,
57- } ,
58- } )
59- . then ( function ( response : { data : { tag_name : string } } ) {
60- return response . data . tag_name . replace ( 'v' , '' ) ;
38+ . get ( 'https://github.com/azure/bicep/releases/latest' )
39+ . then ( function ( response ) {
40+ return response . request . path . split ( '/' ) [ 5 ] . replace ( 'v' , '' ) ;
6141 } )
6242 . catch ( function ( error : {
6343 message : string ;
@@ -69,15 +49,15 @@ export async function getLatestVersionTag(): Promise<string> {
6949 // The request was made and the server responded with a status code
7050 // that falls out of the range of 2xx
7151 throw new Error (
72- `[FATAL] Error while retrieving latest version tag: '${ error . message } '.\nResponse: \n-Data: ' ${ JSON . stringify ( error . response . data ) } ' \n-Status: ' ${ error . response . status } ' \n-Headers: ' ${ JSON . stringify ( error . response . headers ) } ' ` ,
52+ `[FATAL] Error while retrieving latest version tag: '${ error . message } '.` ,
7353 ) ;
7454 } else if ( error . request ) {
7555 throw new Error (
76- `[FATAL] Error while retrieving latest version tag: '${ error . message } '.\nRequest: ' ${ JSON . stringify ( error . request ) } '\nConfig: ' ${ error . config } ' ` ,
56+ `[FATAL] Error while retrieving latest version tag: '${ error . message } '.` ,
7757 ) ;
7858 } else {
7959 throw new Error (
80- `[FATAL] Error while retrieving latest version tag: '${ error . message } '.\nConfig: ' ${ error . config } ' ` ,
60+ `[FATAL] Error while retrieving latest version tag: '${ error . message } '.` ,
8161 ) ;
8262 }
8363 } ) ;
0 commit comments