Skip to content

Commit 966dff5

Browse files
Adding BUILD_ID & BUILD_URL to build_results.txt
1 parent 1487a4e commit 966dff5

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

bin/commands/runs.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ module.exports = function run(args) {
4141
return build.createBuild(bsConfig, zip).then(function (data) {
4242
let message = `${data.message}! ${Constants.userMessages.BUILD_CREATED} with build id: ${data.build_id}`;
4343
let dashboardLink = `${Constants.userMessages.VISIT_DASHBOARD} ${config.dashboardUrl}${data.build_id}`;
44+
utils.exportResults(data.build_id, `${config.dashboardUrl}${data.build_id}`);
4445
logger.info(message);
4546
logger.info(dashboardLink);
4647
utils.sendUsageReport(bsConfig, args, `${message}\n${dashboardLink}`, Constants.messageTypes.SUCCESS, null);

bin/helpers/utils.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22
const os = require("os");
33
const path = require("path");
4+
const fs = require("fs");
45

56
const usageReporting = require('./usageReporting'),
67
logger = require('./logger').winstonLogger,
@@ -120,3 +121,13 @@ exports.configCreated = (args) => {
120121
logger.info(message);
121122
this.sendUsageReport(null, args, message, Constants.messageTypes.SUCCESS, null);
122123
}
124+
125+
exports.exportResults = (buildId, buildUrl) => {
126+
let data = "BUILD_ID=" + buildId + "\nBUILD_URL="+buildUrl;
127+
fs.writeFileSync("log/build_results.txt", data , function(err){
128+
if(err) {
129+
logger.warn(`Couldn't write BUILD_ID with value: ${buildId} to browserstack/build_results.txt`);
130+
logger.warn(`Couldn't write BUILD_URL with value: ${buildUrl} to browserstack/build_results.txt`);
131+
}
132+
});
133+
}

test/unit/bin/commands/runs.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ describe("runs", () => {
436436
zipUploadStub = sandbox.stub();
437437
createBuildStub = sandbox.stub();
438438
deleteZipStub = sandbox.stub();
439+
exportResultsStub = sandbox.stub();
439440
});
440441

441442
afterEach(() => {
@@ -458,7 +459,8 @@ describe("runs", () => {
458459
setBuildName: setBuildNameStub,
459460
setUsageReportingFlag: setUsageReportingFlagStub,
460461
setParallels: setParallelsStub,
461-
getConfigPath: getConfigPathStub
462+
getConfigPath: getConfigPathStub,
463+
exportResults: exportResultsStub
462464
},
463465
"../helpers/capabilityHelper": {
464466
validate: capabilityValidatorStub,

0 commit comments

Comments
 (0)