Skip to content

Commit abd7cd1

Browse files
committed
fixup! ncu-ci: command to start CI for PRs
1 parent fb729a9 commit abd7cd1

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

bin/ncu-ci

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,17 @@ class RunPRJobCommand {
208208
validArgs = false;
209209
}
210210
if (!validArgs) {
211-
// this.setExitCode(1);
211+
// TODO(mmarchini): change to our API once #443 lands
212+
// this.cli.setExitCode(1);
213+
process.exitCode = 1;
212214
return;
213215
}
214216
const jobRunner = new RunPRJob(cli, request, owner, repo, prid);
215-
return jobRunner.start();
217+
if (!jobRunner.start()) {
218+
// TODO(mmarchini): change to our API once #443 lands
219+
// this.cli.setExitCode(1);
220+
process.exitCode = 1;
221+
}
216222
}
217223
}
218224

lib/ci/run_ci.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
var FormData = require('form-data');
3+
const FormData = require('form-data');
44

55
const {
66
CI_DOMAIN,
@@ -26,7 +26,7 @@ class RunPRJob {
2626
const { crumb } = await this.request.json(CI_CRUMB_URL);
2727
return crumb;
2828
} catch (e) {
29-
this.cli.error('Failed to get breadcrumbs');
29+
return false;
3030
}
3131
}
3232

@@ -46,27 +46,32 @@ class RunPRJob {
4646
}
4747

4848
async start() {
49-
this.cli.startSpinner('Validating Jenkins credentials');
49+
const { cli } = this;
50+
cli.startSpinner('Validating Jenkins credentials');
5051
const crumb = await this.getCrumb();
5152

52-
if (!crumb) return;
53-
this.cli.stopSpinner('Jenkins credentials valid');
53+
if (crumb === false) {
54+
cli.stopSpinner('Jenkins credentials invalid',
55+
this.cli.SPINNER_STATUS.FAILED);
56+
return false;
57+
}
58+
cli.stopSpinner('Jenkins credentials valid');
5459

5560
try {
56-
this.cli.startSpinner('Starting PR CI job');
61+
cli.startSpinner('Starting PR CI job');
5762
await this.request.text(CI_PR_URL, {
5863
method: 'POST',
5964
headers: {
6065
'Jenkins-Crumb': crumb
6166
},
6267
body: this.payload
6368
});
64-
this.cli.stopSpinner('Starting PR CI job');
65-
this.cli.ok('CI job started');
69+
cli.stopSpinner('PR CI job successfully started');
6670
} catch (err) {
67-
this.cli.stopSpinner('');
68-
this.cli.error('Failed to start CI');
71+
cli.stopSpinner('Failed to start CI', this.cli.SPINNER_STATUS.FAILED);
72+
return false;
6973
}
74+
return true;
7075
}
7176
}
7277

0 commit comments

Comments
 (0)