@@ -13,6 +13,7 @@ const HttpsProxyAgent = require('https-proxy-agent');
1313const FormData = require ( 'form-data' ) ;
1414const decompress = require ( 'decompress' ) ;
1515const unzipper = require ( "unzipper" ) ;
16+ const { setAxiosProxy } = require ( './helper' ) ;
1617
1718let BUILD_ARTIFACTS_TOTAL_COUNT = 0 ;
1819let BUILD_ARTIFACTS_FAIL_COUNT = 0 ;
@@ -110,10 +111,12 @@ const downloadAndUnzip = async (filePath, fileName, url) => {
110111 logger . debug ( `Downloading build artifact for: ${ filePath } ` )
111112 return new Promise ( async ( resolve , reject ) => {
112113 try {
113- const response = await axios . get ( url , {
114+ const axiosConfig = {
114115 responseType : 'stream' ,
115116 validateStatus : status => ( status >= 200 && status < 300 ) || status === 404
116- } ) ;
117+ } ;
118+ setAxiosProxy ( axiosConfig ) ;
119+ const response = await axios . get ( url , axiosConfig ) ;
117120 if ( response . status != 200 ) {
118121 if ( response . status === 404 ) {
119122 reject ( Constants . userMessages . DOWNLOAD_BUILD_ARTIFACTS_NOT_FOUND ) ;
@@ -195,16 +198,19 @@ const sendUpdatesToBstack = async (bsConfig, buildId, args, options, rawArgs, bu
195198 }
196199
197200 options . formData = data . toString ( ) ;
201+ const axiosConfig = {
202+ auth : {
203+ username : options . auth . username ,
204+ password : options . auth . password
205+ } ,
206+ headers : options . headers
207+ } ;
208+ setAxiosProxy ( axiosConfig ) ;
209+
198210 let responseData = null ;
199211 return new Promise ( async ( resolve , reject ) => {
200212 try {
201- const response = await axios . post ( options . url , data , {
202- auth : {
203- username : options . auth . username ,
204- password : options . auth . password
205- } ,
206- headers : options . headers
207- } ) ;
213+ const response = await axios . post ( options . url , data , axiosConfig ) ;
208214 try {
209215 responseData = response . data ;
210216 } catch ( e ) {
@@ -253,13 +259,7 @@ exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs, buildR
253259 auth : options . auth ,
254260 headers : options . headers
255261 }
256- if ( process . env . HTTP_PROXY ) {
257- options . config . proxy = false ;
258- options . config . httpAgent = new HttpsProxyAgent ( process . env . HTTP_PROXY ) ;
259- } else if ( process . env . HTTPS_PROXY ) {
260- options . config . proxy = false ;
261- options . config . httpAgent = new HttpsProxyAgent ( process . env . HTTPS_PROXY ) ;
262- }
262+ setAxiosProxy ( options . config ) ;
263263 let response ;
264264 try {
265265 response = await axios . get ( options . url , options . config ) ;
0 commit comments