Skip to content

Commit

Permalink
Don't die when viewing older builds
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed Jun 29, 2018
1 parent a075119 commit 0ff5e4e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ async function onBuildKitePublicLogRequest(req, res) {
const pipeline = await buildkiteOrg.getPipelineAsync(buildInfo.pipeline);
pipeline.listBuildsAsync = promisify(pipeline.listBuilds);

// TODO: Add pagination support for older builds
const builds = await pipeline.listBuildsAsync();
const build = builds.find(
(build) => {
Expand All @@ -570,11 +571,14 @@ async function onBuildKitePublicLogRequest(req, res) {
}
}
);
buildInfo.buildNumber = build.number; // replace buildNumber if it's a string (branch name)

if (!build) {
log.warn(`Build ${buildInfo.buildNumber} not found`);
res.status(400).send('');
let msg = `Build ${buildInfo.buildNumber} not found, try <a href="${url}">here</a> instead.`;

// TODO: Add pagination support for older builds
msg += '<p>TODO: Add pagination support for older builds';
log.warn(msg);
res.status(400).send(msg);
return;
}

Expand Down

0 comments on commit 0ff5e4e

Please sign in to comment.