Skip to content

Commit e782b55

Browse files
authored
jenkins: destructure build result after knowing it's not an error (#237)
We've seen some error logs in production suggesting that we get errors back from Jenkins when triggering builds, as the result is `null | undefined`. Destructuring fields out of that result causes unchaught exceptions, meaning the bot process dies. Therefore postponing the destructuring until we're confident the build didn't result in an error.
1 parent b6e54da commit e782b55

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

scripts/trigger-jenkins-build.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,18 @@ function triggerBuildIfValid (options) {
8282
return logger.debug(`Ignoring comment to me by @${options.author} because they are not a repo collaborator`)
8383
}
8484

85-
triggerBuild(options, function onBuildTriggered (err, { jobName, jobId }) {
86-
const jobUrl = `https://ci.nodejs.org/job/${jobName}/${jobId}`
87-
let body = `Lite-CI: ${jobUrl}`
85+
triggerBuild(options, function onBuildTriggered (err, result) {
86+
let body = ''
87+
8888
if (err) {
8989
logger.error(err, 'Error while triggering Jenkins build')
9090
body = 'Sadly, an error occurred when I tried to trigger a build. :('
9191
} else {
92+
const jobUrl = `https://ci.nodejs.org/job/${result.jobName}/${result.jobId}`
9293
logger.info({ jobUrl }, 'Jenkins build started')
94+
body = `Lite-CI: ${jobUrl}`
9395
}
96+
9497
createPrComment(options, body)
9598
})
9699
})

0 commit comments

Comments
 (0)