Skip to content

Commit 0cb463f

Browse files
committed
Adding build callback url and username and access key
- Override username and access key from the command line args. - Chnaged project notify url to build callback url.
1 parent 225d402 commit 0cb463f

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

bin/commands/runs.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ module.exports = function run(args) {
1515
return utils.validateBstackJson(bsConfigPath).then(function (bsConfig) {
1616
utils.setUsageReportingFlag(bsConfig, args.disableUsageReporting);
1717

18+
// accept the username from command line if provided
19+
utils.setUsername(bsConfig, args);
20+
21+
// accept the access key from command line if provided
22+
utils.setAccessKey(bsConfig, args);
23+
1824
// Validate browserstack.json values and parallels specified via arguments
1925
return capabilityHelper.validate(bsConfig, args).then(function (validated) {
2026
logger.info(validated);

bin/helpers/capabilityHelper.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const caps = (bsConfig, zip) => {
6666
obj.project = bsConfig.run_settings.project || bsConfig.run_settings.project_name;
6767
obj.customBuildName = bsConfig.run_settings.customBuildName || bsConfig.run_settings.build_name;
6868
obj.callbackURL = bsConfig.run_settings.callback_url;
69-
obj.projectNotifyURL = bsConfig.run_settings.project_notify_URL;
69+
obj.projectNotifyURL = bsConfig.run_settings.build_callback_url;
7070
obj.parallels = bsConfig.run_settings.parallels;
7171
}
7272

@@ -99,7 +99,7 @@ const validate = (bsConfig, args) => {
9999

100100
// validate parallels specified in browserstack.json if parallels are not specified via arguments
101101
if (!Utils.isUndefined(args) && Utils.isUndefined(args.parallels) && !Utils.isParallelValid(bsConfig.run_settings.parallels)) reject(Constants.validationMessages.INVALID_PARALLELS_CONFIGURATION);
102-
102+
103103
// if parallels specified via arguments validate only arguments
104104
if (!Utils.isUndefined(args) && !Utils.isUndefined(args.parallels) && !Utils.isParallelValid(args.parallels)) reject(Constants.validationMessages.INVALID_PARALLELS_CONFIGURATION);
105105

@@ -111,7 +111,7 @@ const validate = (bsConfig, args) => {
111111
}catch(error){
112112
reject(Constants.validationMessages.INVALID_CYPRESS_JSON)
113113
}
114-
114+
115115
resolve(Constants.validationMessages.VALIDATED);
116116
});
117117
}

bin/helpers/utils.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ exports.setParallels = (bsConfig, args) => {
7676
}
7777
}
7878

79+
exports.setUsername = (bsConfig, args) => {
80+
if (!this.isUndefined(args.username)) {
81+
bsConfig['auth']['username'] = args.username;
82+
}
83+
}
84+
85+
exports.setAccessKey = (bsConfig, args) => {
86+
if (!this.isUndefined(args.key)) {
87+
bsConfig['auth']['access_key'] = args.key;
88+
}
89+
}
90+
7991
exports.isUndefined = value => (value === undefined || value === null);
8092

8193
exports.isFloat = value => (Number(value) && Number(value) % 1 !== 0);

test/unit/bin/helpers/capabilityHelper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ describe("capabilityHelper.js", () => {
233233
project_name: "sample project",
234234
build_name: "sample build",
235235
callback_url: "random url",
236-
project_notify_URL: "random url",
236+
build_callback_url: "random url",
237237
},
238238
};
239239
return capabilityHelper
@@ -374,7 +374,7 @@ describe("capabilityHelper.js", () => {
374374
it("validate parallels present in bsconfig run settings (not a number) when not specified in arguments", () => {
375375

376376
bsConfig.run_settings.parallels = "cypress";
377-
377+
378378
return capabilityHelper
379379
.validate(bsConfig, { parallels: undefined })
380380
.then(function (data) {

0 commit comments

Comments
 (0)