diff --git a/bin/commands/generateReport.js b/bin/commands/generateReport.js index 81c6fab8..af375005 100644 --- a/bin/commands/generateReport.js +++ b/bin/commands/generateReport.js @@ -5,13 +5,13 @@ const logger = require("../helpers/logger").winstonLogger, utils = require("../helpers/utils"), reporterHTML = require('../helpers/reporterHTML'), getInitialDetails = require('../helpers/getInitialDetails').getInitialDetails; - +const { isTurboScaleSession } = require('../helpers/atsHelper'); module.exports = function generateReport(args, rawArgs) { let bsConfigPath = utils.getConfigPath(args.cf); let reportGenerator = reporterHTML.reportGenerator; - return utils.validateBstackJson(bsConfigPath).then(function (bsConfig) { + return utils.validateBstackJson(bsConfigPath).then(async function (bsConfig) { // setting setDefaults to {} if not present and set via env variables or via args. utils.setDefaults(bsConfig, args); @@ -21,9 +21,9 @@ module.exports = function generateReport(args, rawArgs) { // accept the access key from command line if provided utils.setAccessKey(bsConfig, args); - getInitialDetails(bsConfig, args, rawArgs).then((buildReportData) => { - - utils.setUsageReportingFlag(bsConfig, args.disableUsageReporting); + try { + let buildReportData = isTurboScaleSession(bsConfig) ? null : await getInitialDetails(bsConfig, args, rawArgs); + utils.setUsageReportingFlag(bsConfig, args.disableUsageReporting); // set cypress config filename utils.setCypressConfigFilename(bsConfig, args); @@ -34,9 +34,9 @@ module.exports = function generateReport(args, rawArgs) { reportGenerator(bsConfig, buildId, args, rawArgs, buildReportData); utils.sendUsageReport(bsConfig, args, 'generate-report called', messageType, errorCode, buildReportData, rawArgs); - }).catch((err) => { + } catch(err) { logger.warn(err); - }); + }; }).catch(function (err) { logger.error(err); utils.setUsageReportingFlag(null, args.disableUsageReporting); diff --git a/bin/commands/runs.js b/bin/commands/runs.js index 57a6d0f9..baa04b12 100644 --- a/bin/commands/runs.js +++ b/bin/commands/runs.js @@ -365,10 +365,10 @@ module.exports = function run(args, rawArgs) { await new Promise(resolve => setTimeout(resolve, 5000)); // download build artifacts - if (exitCode != Constants.BUILD_FAILED_EXIT_CODE && !turboScaleSession) { + if (exitCode != Constants.BUILD_FAILED_EXIT_CODE) { if (utils.nonEmptyArray(bsConfig.run_settings.downloads)) { logger.debug("Downloading build artifacts"); - await downloadBuildArtifacts(bsConfig, data.build_id, args, rawArgs, buildReportData); + await downloadBuildArtifacts(bsConfig, data.build_id, args, rawArgs, buildReportData, turboScaleSession); } // Generate custom report! diff --git a/bin/helpers/buildArtifacts.js b/bin/helpers/buildArtifacts.js index 844ad3b6..cd064fa7 100644 --- a/bin/helpers/buildArtifacts.js +++ b/bin/helpers/buildArtifacts.js @@ -213,13 +213,15 @@ const sendUpdatesToBstack = async (bsConfig, buildId, args, options, rawArgs, bu }); } -exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs, buildReportData = null) => { +exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs, buildReportData = null, isTurboScaleSession = false) => { return new Promise ( async (resolve, reject) => { BUILD_ARTIFACTS_FAIL_COUNT = 0; BUILD_ARTIFACTS_TOTAL_COUNT = 0; let options = { - url: `${config.buildUrl}${buildId}/build_artifacts`, + url: isTurboScaleSession + ? `${config.turboScaleBuildsUrl}/${buildId}/build_artifacts` + : `${config.buildUrl}${buildId}/build_artifacts`, auth: { username: bsConfig.auth.username, password: bsConfig.auth.access_key, diff --git a/bin/helpers/capabilityHelper.js b/bin/helpers/capabilityHelper.js index ae09e260..0467c154 100644 --- a/bin/helpers/capabilityHelper.js +++ b/bin/helpers/capabilityHelper.js @@ -131,6 +131,9 @@ const caps = (bsConfig, zip) => { obj.run_settings = JSON.stringify(bsConfig.run_settings); } + obj.cypress_cli_user_agent = Utils.getUserAgent(); + logger.info(`Cypress CLI User Agent: ${obj.cypress_cli_user_agent}`); + if(obj.parallels === Constants.cliMessages.RUN.DEFAULT_PARALLEL_MESSAGE) obj.parallels = undefined if (obj.project) logger.info(`Project name is: ${obj.project}`); diff --git a/bin/helpers/reporterHTML.js b/bin/helpers/reporterHTML.js index 5859b103..6cf2dfdc 100644 --- a/bin/helpers/reporterHTML.js +++ b/bin/helpers/reporterHTML.js @@ -6,6 +6,7 @@ const fs = require('fs'), Constants = require('./constants'), config = require("./config"), decompress = require('decompress'); +const { isTurboScaleSession } = require('../helpers/atsHelper'); let reportGenerator = (bsConfig, buildId, args, rawArgs, buildReportData, cb) => { let options = { @@ -19,6 +20,10 @@ let reportGenerator = (bsConfig, buildId, args, rawArgs, buildReportData, cb) => }, }; + if (isTurboScaleSession(bsConfig)) { + options.url = `${config.turboScaleBuildsUrl}/${buildId}/custom_report`; + } + logger.debug('Started fetching the build json and html reports.'); return request.get(options, async function (err, resp, body) {