@@ -12,6 +12,9 @@ const logger = require('./logger').winstonLogger,
12
12
config = require ( "./config" ) ;
13
13
14
14
15
+ let BUILD_ARTIFACTS_TOTAL_COUNT = 0 ;
16
+ let BUILD_ARTIFACTS_FAIL_COUNT = 0 ;
17
+
15
18
const parseAndDownloadArtifacts = async ( buildId , data ) => {
16
19
return new Promise ( async ( resolve , reject ) => {
17
20
let all_promises = [ ] ;
@@ -23,9 +26,9 @@ const parseAndDownloadArtifacts = async (buildId, data) => {
23
26
let sessionId = sessions [ j ] ;
24
27
let filePath = path . join ( './' , 'build_artifacts' , buildId , comb , sessionId ) ;
25
28
let fileName = 'build_artifacts.zip' ;
26
- process . env . BUILD_ARTIFACTS_TOTAL_COUNT = Number ( process . env . BUILD_ARTIFACTS_TOTAL_COUNT ) + 1
29
+ BUILD_ARTIFACTS_TOTAL_COUNT += 1 ;
27
30
all_promises . push ( downloadAndUnzip ( filePath , fileName , data [ comb ] [ sessionId ] ) . catch ( ( error ) => {
28
- process . env . BUILD_ARTIFACTS_FAIL_COUNT = Number ( process . env . BUILD_ARTIFACTS_FAIL_COUNT ) + 1 ;
31
+ BUILD_ARTIFACTS_FAIL_COUNT = BUILD_ARTIFACTS_FAIL_COUNT + 1 ;
29
32
reject ( error ) ;
30
33
} ) ) ;
31
34
}
@@ -142,8 +145,8 @@ const sendUpdatesToBstack = async (bsConfig, buildId, args, options) => {
142
145
let data = {
143
146
feature_usage : {
144
147
downloads : {
145
- eligible_download_folders : Number ( process . env . BUILD_ARTIFACTS_TOTAL_COUNT ) ,
146
- successfully_downloaded_folders : Number ( process . env . BUILD_ARTIFACTS_TOTAL_COUNT ) - Number ( process . env . BUILD_ARTIFACTS_FAIL_COUNT )
148
+ eligible_download_folders : BUILD_ARTIFACTS_TOTAL_COUNT ,
149
+ successfully_downloaded_folders : BUILD_ARTIFACTS_TOTAL_COUNT - BUILD_ARTIFACTS_FAIL_COUNT
147
150
} ,
148
151
reporter : reporter
149
152
}
@@ -157,8 +160,8 @@ const sendUpdatesToBstack = async (bsConfig, buildId, args, options) => {
157
160
}
158
161
159
162
exports . downloadBuildArtifacts = async ( bsConfig , buildId , args ) => {
160
- process . env . BUILD_ARTIFACTS_FAIL_COUNT = 0 ;
161
- process . env . BUILD_ARTIFACTS_TOTAL_COUNT = 0 ;
163
+ BUILD_ARTIFACTS_FAIL_COUNT = 0 ;
164
+ BUILD_ARTIFACTS_TOTAL_COUNT = 0 ;
162
165
163
166
let url = `${ config . buildUrl } ${ buildId } /build_artifacts` ;
164
167
let options = {
@@ -182,9 +185,9 @@ exports.downloadBuildArtifacts = async (bsConfig, buildId, args) => {
182
185
await createDirectories ( buildId , buildDetails ) ;
183
186
await parseAndDownloadArtifacts ( buildId , buildDetails ) ;
184
187
185
- if ( process . env . BUILD_ARTIFACTS_FAIL_COUNT > 0 ) {
188
+ if ( BUILD_ARTIFACTS_FAIL_COUNT > 0 ) {
186
189
messageType = Constants . messageTypes . ERROR ;
187
- message = Constants . userMessages . DOWNLOAD_BUILD_ARTIFACTS_FAILED . replace ( '<build-id>' , buildId ) . replace ( '<machine-count>' , process . env . BUILD_ARTIFACTS_FAIL_COUNT ) ;
190
+ message = Constants . userMessages . DOWNLOAD_BUILD_ARTIFACTS_FAILED . replace ( '<build-id>' , buildId ) . replace ( '<machine-count>' , BUILD_ARTIFACTS_FAIL_COUNT ) ;
188
191
logger . error ( message ) ;
189
192
} else {
190
193
messageType = Constants . messageTypes . SUCCESS ;
@@ -198,13 +201,12 @@ exports.downloadBuildArtifacts = async (bsConfig, buildId, args) => {
198
201
messageType = Constants . messageTypes . ERROR ;
199
202
errorCode = 'api_failed_build_artifacts' ;
200
203
201
- if ( process . env . BUILD_ARTIFACTS_FAIL_COUNT > 0 ) {
204
+ if ( BUILD_ARTIFACTS_FAIL_COUNT > 0 ) {
202
205
messageType = Constants . messageTypes . ERROR ;
203
- message = Constants . userMessages . DOWNLOAD_BUILD_ARTIFACTS_FAILED . replace ( '<build-id>' , buildId ) . replace ( '<machine-count>' , process . env . BUILD_ARTIFACTS_FAIL_COUNT ) ;
206
+ message = Constants . userMessages . DOWNLOAD_BUILD_ARTIFACTS_FAILED . replace ( '<build-id>' , buildId ) . replace ( '<machine-count>' , BUILD_ARTIFACTS_FAIL_COUNT ) ;
204
207
logger . error ( message ) ;
205
208
} else {
206
209
logger . error ( 'Downloading the build artifacts failed.' ) ;
207
- logger . error ( err ) ;
208
210
}
209
211
210
212
utils . sendUsageReport ( bsConfig , args , err , messageType , errorCode ) ;
0 commit comments