Skip to content

Commit

Permalink
Add some docs
Browse files Browse the repository at this point in the history
  • Loading branch information
HelloCore committed Jun 24, 2019
1 parent c66bb6e commit 2209b3b
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 3 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ review.

You can use Danger to codify your teams norms, leaving humans to think about harder problems.

Danger JS works with GitHub or BitBucket Server for code review, then with: Travis CI, GitLab CI, Circle CI, Semaphore, GitHub Actions, Jenkins, Docker Cloud, Bitrise, surf-build, Codeship, Drone, Buildkite, Nevercode, buddybuild,
TeamCity, Visual Studio Team Services, Screwdriver, Concourse, Netlify, CodeBuild, Codefresh or AppCenter.
Danger JS works with GitHub, BitBucket Server, BitBucket Cloud for code review, then with: Travis CI, GitLab CI, Circle
CI, Semaphore, GitHub Actions, Jenkins, Docker Cloud, Bitrise, surf-build, Codeship, Drone, Buildkite, Nevercode,
buddybuild, TeamCity, Visual Studio Team Services, Screwdriver, Concourse, Netlify, CodeBuild, Codefresh, AppCenter, or
BitBucket Pipelines.

[![npm](https://img.shields.io/npm/v/danger.svg)](https://www.npmjs.com/package/danger)
[![Build Status](https://travis-ci.org/danger/danger-js.svg?branch=master)](https://travis-ci.org/danger/danger-js)
Expand Down
8 changes: 8 additions & 0 deletions docs/guides/the_dangerfile.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ export DANGER_BITBUCKETSERVER_HOST='xxxx' DANGER_BITBUCKETSERVER_USERNAME='yyyy'

# or for BitBucket by username and personal access token
export DANGER_BITBUCKETSERVER_HOST='xxxx' DANGER_BITBUCKETSERVER_USERNAME='yyyy' DANGER_BITBUCKETSERVER_TOKEN='zzzz'

# or for BitBucket Cloud by username (from Account Settings page), password (App-password with Read Pull requests Permission is enough), and UUID
# We need UUID for updating comment, you can get it from the link on your home page of bitbucket.org
# For example, https://bitbucket.org/%7Bzzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz%7D/
# Then replace "%7B" with "{" and "%7D" with "}"
export DANGER_BITBUCKETCLOUD_USERNAME='xxxx'
export DANGER_BITBUCKETCLOUD_PASSWORD='yyyy'
export DANGER_BITBUCKETCLOUD_UUID='{zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz}'
```

Then the danger CLI will use authenticated API calls, which don't get this by API limits.
Expand Down
51 changes: 51 additions & 0 deletions docs/usage/bitbucket_cloud.html.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
title: Danger + BitBucket Cloud
subtitle: Dangerous bits
layout: guide_js
order: 4
blurb: An overview of using Danger with BitBucket Cloud, and some examples
---

To use Danger JS with BitBucket Cloud: you'll need to create a new account for Danger to use, then set the following
environment variables on your CI:

- `DANGER_BITBUCKETCLOUD_USERNAME` = The username for the account used to comment, as shown on
https://bitbucket.org/account/
- `DANGER_BITBUCKETCLOUD_PASSWORD` = The password for the account used to comment, you could use
[App passwords](https://confluence.atlassian.com/bitbucket/app-passwords-828781300.html#Apppasswords-Aboutapppasswords)
with Read Pull Requests Permission.

We need UUID for updating comment, you can get it from the link on your home page of bitbucket.org. Then replace `%7B`
with `{` and `%7D` with `}`.

For example, the UUID of `https://bitbucket.org/%7Bzzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz%7D/` will be
`{zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz}`

- `DANGER_BITBUCKETCLOUD_UUID` = The uuid for the account used to comment.

Then in your Dangerfiles you will have a fully fleshed out `danger.bitbucket_cloud` object to work with. For example:

```ts
import { danger, warn } from "danger"

if (danger.bitbucket_cloud.pr.title.includes("WIP")) {
warn("PR is considered WIP")
}
```

The DSL is expansive, you can see all the details inside the [Danger JS Reference][ref], but the TLDR is:

```ts
danger.bitbucket_cloud.

/** The pull request and repository metadata */
metadata: RepoMetaData
/** The PR metadata */
pr: BitBucketCloudPRDSL
/** The commits associated with the pull request */
commits: BitBucketCloudCommit[]
/** The comments on the pull request */
comments: BitBucketCloudPRComment[]
/** The activities such as OPENING, COMMENTING, CLOSING, MERGING or UPDATING a pull request */
activities: BitBucketCloudPRActivity[]
```
20 changes: 19 additions & 1 deletion source/ci_source/providers/BitbucketPipelines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,25 @@ import { ensureEnvKeysExist, ensureEnvKeysAreInt } from "../ci_source_helpers"
/**
* ### CI Setup
*
* Bitbucket Pipeline
* Install dependencies and add a danger step to your `bitbucket-pipelines.yml`.
* For improving the performance, you may need to cache `node_modules`.
*
* ```yml
* image: node:10.15.0
* pipelines:
* pull-requests:
* "**":
* - step:
* caches:
* - node
* script:
* - export LANG="C.UTF-8"
* - yarn install
* - yarn danger ci
* definitions:
* caches:
* node: node_modules
* ```
*
* ### Token Setup
*
Expand Down

0 comments on commit 2209b3b

Please sign in to comment.