@@ -13,6 +13,7 @@ const HttpsProxyAgent = require('https-proxy-agent');
13
13
const FormData = require ( 'form-data' ) ;
14
14
const decompress = require ( 'decompress' ) ;
15
15
const unzipper = require ( "unzipper" ) ;
16
+ const { setAxiosProxy } = require ( './helper' ) ;
16
17
17
18
let BUILD_ARTIFACTS_TOTAL_COUNT = 0 ;
18
19
let BUILD_ARTIFACTS_FAIL_COUNT = 0 ;
@@ -110,10 +111,12 @@ const downloadAndUnzip = async (filePath, fileName, url) => {
110
111
logger . debug ( `Downloading build artifact for: ${ filePath } ` )
111
112
return new Promise ( async ( resolve , reject ) => {
112
113
try {
113
- const response = await axios . get ( url , {
114
+ const axiosConfig = {
114
115
responseType : 'stream' ,
115
116
validateStatus : status => ( status >= 200 && status < 300 ) || status === 404
116
- } ) ;
117
+ } ;
118
+ setAxiosProxy ( axiosConfig ) ;
119
+ const response = await axios . get ( url , axiosConfig ) ;
117
120
if ( response . status != 200 ) {
118
121
if ( response . status === 404 ) {
119
122
reject ( Constants . userMessages . DOWNLOAD_BUILD_ARTIFACTS_NOT_FOUND ) ;
@@ -195,16 +198,19 @@ const sendUpdatesToBstack = async (bsConfig, buildId, args, options, rawArgs, bu
195
198
}
196
199
197
200
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
+
198
210
let responseData = null ;
199
211
return new Promise ( async ( resolve , reject ) => {
200
212
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 ) ;
208
214
try {
209
215
responseData = response . data ;
210
216
} catch ( e ) {
@@ -253,13 +259,7 @@ exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs, buildR
253
259
auth : options . auth ,
254
260
headers : options . headers
255
261
}
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 ) ;
263
263
let response ;
264
264
try {
265
265
response = await axios . get ( options . url , options . config ) ;
0 commit comments