mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-06-12 10:29:35 +00:00
acbcc53872
When executing a backend step, in case of failure of the specific step, the run is marked as errored but the step error is missing. Added: 1. Log for the backend error (without trace) 2. Mark the step as errored with exit code 126 (Could not execute). Co-authored-by: Zav Shotan <zshotan@bloomberg.net> Co-authored-by: Anton Bracke <anton@ju60.de>
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import { ref } from 'vue';
|
|
|
|
import { BuildLog, BuildProc } from '~/lib/api/types';
|
|
import { isProcFinished, isProcRunning } from '~/utils/helpers';
|
|
|
|
import useApiClient from './useApiClient';
|
|
|
|
const apiClient = useApiClient();
|
|
|
|
export default () => {
|
|
const logs = ref<BuildLog[] | undefined>();
|
|
const proc = ref<BuildProc>();
|
|
let stream: EventSource | undefined;
|
|
|
|
function onLogsUpdate(data: BuildLog) {
|
|
if (data.proc === proc.value?.name) {
|
|
logs.value = [...(logs.value || []), data];
|
|
}
|
|
}
|
|
|
|
function unload() {
|
|
if (stream) {
|
|
stream.close();
|
|
}
|
|
}
|
|
|
|
async function load(owner: string, repo: string, build: number, _proc: BuildProc) {
|
|
unload();
|
|
|
|
proc.value = _proc;
|
|
logs.value = [];
|
|
|
|
// we do not have logs for skipped jobs
|
|
if (_proc.state === 'skipped' || _proc.state === 'killed') {
|
|
return;
|
|
}
|
|
|
|
if (_proc.error) {
|
|
logs.value = undefined;
|
|
} else if (isProcFinished(_proc)) {
|
|
logs.value = await apiClient.getLogs(owner, repo, build, _proc.pid);
|
|
} else if (isProcRunning(_proc)) {
|
|
// load stream of parent process (which receives all child processes logs)
|
|
stream = apiClient.streamLogs(owner, repo, build, _proc.ppid, onLogsUpdate);
|
|
}
|
|
}
|
|
|
|
return { logs, load, unload };
|
|
};
|