Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: async createGhStatus
  • Loading branch information
mmarchini committed Aug 15, 2020
commit 3cf7cb6af78674f10a8e729609e16523f8459176
36 changes: 17 additions & 19 deletions lib/push-jenkins-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function pushStarted (options, build, cb) {
message: build.message || 'running tests'
}, options)

createGhStatus(statusOpts, logger, cb)
createGhStatus(statusOpts, logger).then(cb).catch(cb)
})
}

Expand Down Expand Up @@ -109,24 +109,22 @@ function findLatestCommitInPr (options, cb, pageNumber = 1) {
})
}

function createGhStatus (options, logger, cb) {
githubClient.repos.createStatus({
owner: options.owner,
repo: options.repo,
sha: options.sha,
target_url: options.url,
context: options.context,
state: options.state,
description: options.message
}, (err, res) => {
if (err) {
logger.error(err, 'Error while updating Jenkins / GitHub PR status')
cb(err)
return
}
logger.info('Jenkins / Github PR status updated')
cb(null)
})
async function createGhStatus (options, logger) {
try {
await githubClient.repos.createStatus({
owner: options.owner,
repo: options.repo,
sha: options.sha,
target_url: options.url,
context: options.context,
state: options.state,
description: options.message
})
} catch (err) {
logger.error(err, 'Error while updating Jenkins / GitHub PR status')
throw err
}
logger.info('Jenkins / Github PR status updated')
}

function validate (payload) {
Expand Down