Skip to content

Commit

Permalink
chore: add usage logging for build artifacts failures
Browse files Browse the repository at this point in the history
  • Loading branch information
asambstack committed Oct 8, 2024
1 parent 8c975cb commit 18d8df8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bin/helpers/buildArtifacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ const parseAndDownloadArtifacts = async (buildId, data, bsConfig, args, rawArgs,
utils.sendUsageReport(bsConfig, args, warningMessage, Constants.messageTypes.ERROR, 'build_artifacts_not_found', buildReportData, rawArgs);
} else {
BUILD_ARTIFACTS_FAIL_COUNT += 1;
const errorMsg = `Error downloading build artifacts for ${sessionId} with error: ${error}`;
logger.debug(errorMsg);
utils.sendUsageReport(bsConfig, args, errorMsg, Constants.messageTypes.ERROR, 'build_artifacts_parse_error', buildReportData, rawArgs);
}
// delete malformed zip if present
let tmpFilePath = path.join(filePath, fileName);
Expand Down Expand Up @@ -102,14 +105,16 @@ const downloadAndUnzip = async (filePath, fileName, url) => {
let tmpFilePath = path.join(filePath, fileName);
const writer = fs.createWriteStream(tmpFilePath);

logger.debug(`Downloading build artifact for: ${filePath}`)
return new Promise(async (resolve, reject) => {
request.get(url).on('response', function(response) {

if(response.statusCode != 200) {
if (response.statusCode === 404) {
reject(Constants.userMessages.DOWNLOAD_BUILD_ARTIFACTS_NOT_FOUND);
}
reject();
const errorMsg = `Non 200 status code, got status code: ${response.statusCode}`;
reject(errorMsg);
} else {
//ensure that the user can call `then()` only when the file has
//been downloaded entirely.
Expand Down

0 comments on commit 18d8df8

Please sign in to comment.