-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add BitBucket pull request parser and add documentation
- Loading branch information
Showing
6 changed files
with
55 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import StatusManager from 'backend/status/manager'; | ||
import { BitBucketPullRequestWebhook } from 'types/bitbucket'; | ||
import Status from 'types/status'; | ||
|
||
class BitBucketPullRequestParser { | ||
parse(id: string, pr: BitBucketPullRequestWebhook): Status { | ||
let status = StatusManager.getStatus(id); | ||
|
||
if (!status) { | ||
status = { | ||
id, | ||
project: `${pr.repository.workspace.name} / ${pr.repository.name}`, | ||
state: 'info', | ||
source: 'bitbucket', | ||
time: new Date().toUTCString(), | ||
processes: [], | ||
}; | ||
} | ||
|
||
const commitUser = pr.actor; | ||
return { | ||
...status, | ||
branch: pr.pullrequest.source.branch.name, | ||
username: commitUser.display_name, | ||
userUrl: commitUser.links.html.href, | ||
userImage: commitUser.links.avatar.href, | ||
mergeTitle: pr.pullrequest.title, | ||
mergeUrl: pr.pullrequest.links.html.href, | ||
projectImage: pr.repository.links.avatar.href, | ||
sourceUrl: pr.repository.links.html.href, | ||
time: new Date().toUTCString(), | ||
}; | ||
} | ||
} | ||
|
||
export default new BitBucketPullRequestParser(); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# BitBucket | ||
|
||
![BitBucket status example](../images/status/bitbucket.png) | ||
|
||
## Adding webhook | ||
|
||
In your BitBucket project settings, open the webhooks page, and add a webhook: | ||
|
||
- _WebHook URL_: `cimonitor.example.com/webhook/bitbucket` (replace your domain name) | ||
- _Content type_: `application/json` | ||
- _Secret:_ insert the same password you've defined to access your settings | ||
- _What event?_ Select all the events to unluck the most potential. Supported are merge request, pushes and builds. | ||
- Make sure the webhook is active | ||
|
||
Add your webhook! All new builds should become visible on your CIMonitor. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters