Skip to content

Commit

Permalink
Fix some copy/paste log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
rocketeerbkw committed Jan 29, 2019
1 parent 70ab1b8 commit 48713ba
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ async function bitbucketPullRequestUpdated(webhook: WebhookRequestData, project:
body,
} = webhook;

console.log(body);
const meta = {
projectName: project.name,
pullrequestTitle: body.pullrequest.title,
pullrequestNumber: body.pullrequest.id,
pullrequestUrl: body.pullrequest.destination.repository.links.html.href,
repoName: body.repository.full_name,
repoUrl: body.repository.links.html.href,
}

const headBranchName = body.pullrequest.source.branch.name
const headSha = body.pullrequest.source.commit.hash
Expand Down Expand Up @@ -51,7 +58,7 @@ async function bitbucketPullRequestUpdated(webhook: WebhookRequestData, project:
case "UnknownActiveSystem":
// These are not real errors and also they will happen many times. We just log them locally but not throw an error
sendToLagoonLogs('info', project.name, uuid, `${webhooktype}:${event}:handledButNoTask`, meta,
`*[${project.name}]* PR ${body.object_attributes.id} opened. No remove task created, reason: ${error}`
`*[${project.name}]* PR ${body.object_attributes.id} updated. No deploy task created, reason: ${error}`
)
return;

Expand Down
10 changes: 9 additions & 1 deletion services/webhooks2tasks/src/handlers/githubPullRequestOpened.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ async function githubPullRequestOpened(webhook: WebhookRequestData, project: Pro
const baseBranchName = body.pull_request.base.ref
const baseSha = body.pull_request.base.sha

const meta = {
projectName: project.name,
pullrequestTitle: body.pull_request.title,
pullrequestNumber: body.number,
pullrequestUrl: body.pull_request.html_url,
repoName: body.repository.full_name,
repoUrl: body.repository.html_url,
}

const data: deployData = {
repoUrl: body.repository.html_url,
Expand Down Expand Up @@ -50,7 +58,7 @@ async function githubPullRequestOpened(webhook: WebhookRequestData, project: Pro
case "UnknownActiveSystem":
// These are not real errors and also they will happen many times. We just log them locally but not throw an error
sendToLagoonLogs('info', project.name, uuid, `${webhooktype}:${event}:handledButNoTask`, meta,
`*[${project.name}]* PR ${body.number} opened. No remove task created, reason: ${error}`
`*[${project.name}]* PR ${body.number} opened. No deploy task created, reason: ${error}`
)
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,18 @@ async function githubPullRequestSynchronize(webhook: WebhookRequestData, project
body,
} = webhook;

const meta = {
projectName: project.name,
pullrequestTitle: body.pull_request.title,
pullrequestNumber: body.number,
pullrequestUrl: body.pull_request.html_url,
repoName: body.repository.full_name,
repoUrl: body.repository.html_url,
}

// Don't trigger deploy if only the PR body was edited.
if (skipRedeploy(body)) {
sendToLagoonLogs('info', project.name, uuid, `${webhooktype}:${event}:handledButNoTask`, {},
sendToLagoonLogs('info', project.name, uuid, `${webhooktype}:${event}:handledButNoTask`, meta,
`*[${project.name}]* PR ${body.number} updated. No deploy task created, reason: Only body changed`
)
return;
Expand Down Expand Up @@ -68,7 +77,7 @@ async function githubPullRequestSynchronize(webhook: WebhookRequestData, project
case "UnknownActiveSystem":
// These are not real errors and also they will happen many times. We just log them locally but not throw an error
sendToLagoonLogs('info', project.name, uuid, `${webhooktype}:${event}:handledButNoTask`, meta,
`*[${project.name}]* PR ${body.number} opened. No remove task created, reason: ${error}`
`*[${project.name}]* PR ${body.number} opened. No deploy task created, reason: ${error}`
)
return;

Expand Down
11 changes: 10 additions & 1 deletion services/webhooks2tasks/src/handlers/gitlabPullRequestOpened.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ async function gitlabPullRequestOpened(webhook: WebhookRequestData, project: Pro
body,
} = webhook;

const meta = {
projectName: project.name,
pullrequestNumber: body.object_attributes.id,
pullrequestTitle: body.object_attributes.title,
pullrequestUrl: body.object_attributes.url,
repoName: body.object_attributes.target.name,
repoUrl: body.object_attributes.target.web_url,
}

const headBranchName = body.object_attributes.source_branch
const headSha = body.object_attributes.last_commit.id
const baseBranchName = body.object_attributes.target_branch
Expand Down Expand Up @@ -50,7 +59,7 @@ async function gitlabPullRequestOpened(webhook: WebhookRequestData, project: Pro
case "UnknownActiveSystem":
// These are not real errors and also they will happen many times. We just log them locally but not throw an error
sendToLagoonLogs('info', project.name, uuid, `${webhooktype}:${event}:handledButNoTask`, meta,
`*[${project.name}]* PR ${body.object_attributes.id} opened. No remove task created, reason: ${error}`
`*[${project.name}]* PR ${body.object_attributes.id} opened. No deploy task created, reason: ${error}`
)
return;

Expand Down
11 changes: 10 additions & 1 deletion services/webhooks2tasks/src/handlers/gitlabPullRequestUpdated.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ async function gitlabPullRequestUpdated(webhook: WebhookRequestData, project: Pr
body,
} = webhook;

const meta = {
projectName: project.name,
pullrequestNumber: body.object_attributes.id,
pullrequestTitle: body.object_attributes.title,
pullrequestUrl: body.object_attributes.url,
repoName: body.object_attributes.target.name,
repoUrl: body.object_attributes.target.web_url,
}

const headBranchName = body.object_attributes.source_branch
const headSha = body.object_attributes.last_commit.id
const baseBranchName = body.object_attributes.target_branch
Expand Down Expand Up @@ -51,7 +60,7 @@ async function gitlabPullRequestUpdated(webhook: WebhookRequestData, project: Pr
case "UnknownActiveSystem":
// These are not real errors and also they will happen many times. We just log them locally but not throw an error
sendToLagoonLogs('info', project.name, uuid, `${webhooktype}:${event}:handledButNoTask`, meta,
`*[${project.name}]* PR ${body.object_attributes.id} opened. No remove task created, reason: ${error}`
`*[${project.name}]* PR ${body.object_attributes.id} updated. No deploy task created, reason: ${error}`
)
return;

Expand Down

0 comments on commit 48713ba

Please sign in to comment.