mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[dev-utils/ship-ci-stats] fail when CI stats is down (#90678)
Co-authored-by: spalger <spalger@users.noreply.github.com>
This commit is contained in:
parent
54863889d4
commit
3ef3e9324f
2 changed files with 12 additions and 4 deletions
|
@ -109,7 +109,7 @@ export class CiStatsReporter {
|
|||
},
|
||||
});
|
||||
|
||||
return;
|
||||
return true;
|
||||
} catch (error) {
|
||||
if (!error?.request) {
|
||||
// not an axios error, must be a usage error that we should notify user about
|
||||
|
|
|
@ -10,7 +10,7 @@ import Path from 'path';
|
|||
import Fs from 'fs';
|
||||
|
||||
import { CiStatsReporter } from './ci_stats_reporter';
|
||||
import { run, createFlagError } from '../run';
|
||||
import { run, createFlagError, createFailError } from '../run';
|
||||
|
||||
export function shipCiStatsCli() {
|
||||
run(
|
||||
|
@ -23,12 +23,20 @@ export function shipCiStatsCli() {
|
|||
}
|
||||
|
||||
const reporter = CiStatsReporter.fromEnv(log);
|
||||
|
||||
if (!reporter.isEnabled()) {
|
||||
throw createFailError('unable to initilize the CI Stats reporter');
|
||||
}
|
||||
|
||||
for (const path of metricPaths) {
|
||||
// resolve path from CLI relative to CWD
|
||||
const abs = Path.resolve(path);
|
||||
const json = Fs.readFileSync(abs, 'utf8');
|
||||
await reporter.metrics(JSON.parse(json));
|
||||
log.success('shipped metrics from', path);
|
||||
if (await reporter.metrics(JSON.parse(json))) {
|
||||
log.success('shipped metrics from', path);
|
||||
} else {
|
||||
throw createFailError('failed to ship metrics');
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue