|
| 1 | +--- |
| 2 | +title: Linking code from Bitbucket Cloud |
| 3 | +sidebarTitle: Bitbucket Cloud |
| 4 | +--- |
| 5 | + |
| 6 | +import BitbucketToken from '/snippets/bitbucket-token.mdx'; |
| 7 | +import BitbucketAppPassword from '/snippets/bitbucket-app-password.mdx'; |
| 8 | + |
| 9 | +## Examples |
| 10 | + |
| 11 | +<AccordionGroup> |
| 12 | + <Accordion title="Sync individual repos"> |
| 13 | + ```json |
| 14 | + { |
| 15 | + "type": "bitbucket", |
| 16 | + "deploymentType": "cloud", |
| 17 | + "repos": [ |
| 18 | + "myWorkspace/myRepo" |
| 19 | + ] |
| 20 | + } |
| 21 | + ``` |
| 22 | + </Accordion> |
| 23 | + <Accordion title="Sync all repos in a workspace"> |
| 24 | + ```json |
| 25 | + { |
| 26 | + "type": "bitbucket", |
| 27 | + "deploymentType": "cloud", |
| 28 | + "workspaces": [ |
| 29 | + "myWorkspace" |
| 30 | + ] |
| 31 | + } |
| 32 | + ``` |
| 33 | + </Accordion> |
| 34 | + <Accordion title="Sync all repos in a project"> |
| 35 | + ```json |
| 36 | + { |
| 37 | + "type": "bitbucket", |
| 38 | + "deploymentType": "cloud", |
| 39 | + "projects": [ |
| 40 | + "myProject" |
| 41 | + ] |
| 42 | + } |
| 43 | + ``` |
| 44 | + </Accordion> |
| 45 | + <Accordion title="Exclude repos from syncing"> |
| 46 | + ```json |
| 47 | + { |
| 48 | + "type": "bitbucket", |
| 49 | + "deploymentType": "cloud", |
| 50 | + // Include all repos in my-workspace... |
| 51 | + "workspaces": [ |
| 52 | + "myWorkspace" |
| 53 | + ], |
| 54 | + // ...except: |
| 55 | + "exclude": { |
| 56 | + // repos that are archived |
| 57 | + "archived": true, |
| 58 | + // repos that are forks |
| 59 | + "forks": true, |
| 60 | + // repos that match these glob patterns |
| 61 | + "repos": [ |
| 62 | + "myWorkspace/repo1", |
| 63 | + "myWorkspace2/*" |
| 64 | + ] |
| 65 | + } |
| 66 | + } |
| 67 | + ``` |
| 68 | + </Accordion> |
| 69 | +</AccordionGroup> |
| 70 | + |
| 71 | +## Authenticating with Bitbucket Cloud |
| 72 | + |
| 73 | +In order to index private repositories, you'll need to provide authentication credentials. You can do this using an `App Password` or an `Access Token` |
| 74 | + |
| 75 | +<Tabs> |
| 76 | + <Tab title="App Password"> |
| 77 | + Navigate to the [app password creation page](https://bitbucket.org/account/settings/app-passwords/) and create an app password. Ensure that it has the proper permissions for the scope |
| 78 | + of info you want to fetch (i.e. workspace, project, and/or repo level) |
| 79 | +  |
| 80 | + |
| 81 | + Next, provide your username + app password pair to Sourcebot: |
| 82 | + |
| 83 | + <BitbucketAppPassword /> |
| 84 | + </Tab> |
| 85 | + <Tab title="Access Token"> |
| 86 | + Create an access token for the desired scope (repo, project, or workspace). Visit the official [Bitbucket Cloud docs](https://support.atlassian.com/bitbucket-cloud/docs/access-tokens/) |
| 87 | + for more info. |
| 88 | + |
| 89 | + Next, provide the access token to Sourcebot: |
| 90 | + |
| 91 | + <BitbucketToken /> |
| 92 | + </Tab> |
| 93 | +</Tabs> |
| 94 | + |
| 95 | + |
| 96 | +## Schema reference |
| 97 | + |
| 98 | +<Accordion title="Reference"> |
| 99 | +[schemas/v3/bitbucket.json](https://github.com/sourcebot-dev/sourcebot/blob/main/schemas/v3/bitbucket.json) |
| 100 | + |
| 101 | +```json |
| 102 | +{ |
| 103 | + "$schema": "http://json-schema.org/draft-07/schema#", |
| 104 | + "type": "object", |
| 105 | + "title": "BitbucketConnectionConfig", |
| 106 | + "properties": { |
| 107 | + "type": { |
| 108 | + "const": "bitbucket", |
| 109 | + "description": "Bitbucket configuration" |
| 110 | + }, |
| 111 | + "user": { |
| 112 | + "type": "string", |
| 113 | + "description": "The username to use for authentication. Only needed if token is an app password." |
| 114 | + }, |
| 115 | + "token": { |
| 116 | + "$ref": "./shared.json#/definitions/Token", |
| 117 | + "description": "An authentication token.", |
| 118 | + "examples": [ |
| 119 | + { |
| 120 | + "secret": "SECRET_KEY" |
| 121 | + } |
| 122 | + ] |
| 123 | + }, |
| 124 | + "url": { |
| 125 | + "type": "string", |
| 126 | + "format": "url", |
| 127 | + "default": "https://api.bitbucket.org/2.0", |
| 128 | + "description": "Bitbucket URL", |
| 129 | + "examples": [ |
| 130 | + "https://bitbucket.example.com" |
| 131 | + ], |
| 132 | + "pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$" |
| 133 | + }, |
| 134 | + "deploymentType": { |
| 135 | + "type": "string", |
| 136 | + "enum": ["cloud", "server"], |
| 137 | + "default": "cloud", |
| 138 | + "description": "The type of Bitbucket deployment" |
| 139 | + }, |
| 140 | + "workspaces": { |
| 141 | + "type": "array", |
| 142 | + "items": { |
| 143 | + "type": "string" |
| 144 | + }, |
| 145 | + "description": "List of workspaces to sync. Ignored if deploymentType is server." |
| 146 | + }, |
| 147 | + "projects": { |
| 148 | + "type": "array", |
| 149 | + "items": { |
| 150 | + "type": "string" |
| 151 | + }, |
| 152 | + "description": "List of projects to sync" |
| 153 | + }, |
| 154 | + "repos": { |
| 155 | + "type": "array", |
| 156 | + "items": { |
| 157 | + "type": "string" |
| 158 | + }, |
| 159 | + "description": "List of repos to sync" |
| 160 | + }, |
| 161 | + "exclude": { |
| 162 | + "type": "object", |
| 163 | + "properties": { |
| 164 | + "archived": { |
| 165 | + "type": "boolean", |
| 166 | + "default": false, |
| 167 | + "description": "Exclude archived repositories from syncing." |
| 168 | + }, |
| 169 | + "forks": { |
| 170 | + "type": "boolean", |
| 171 | + "default": false, |
| 172 | + "description": "Exclude forked repositories from syncing." |
| 173 | + }, |
| 174 | + "repos": { |
| 175 | + "type": "array", |
| 176 | + "items": { |
| 177 | + "type": "string" |
| 178 | + }, |
| 179 | + "examples": [ |
| 180 | + [ |
| 181 | + "cloud_workspace/repo1", |
| 182 | + "server_project/repo2" |
| 183 | + ] |
| 184 | + ], |
| 185 | + "description": "List of specific repos to exclude from syncing." |
| 186 | + } |
| 187 | + }, |
| 188 | + "additionalProperties": false |
| 189 | + }, |
| 190 | + "revisions": { |
| 191 | + "$ref": "./shared.json#/definitions/GitRevisions" |
| 192 | + } |
| 193 | + }, |
| 194 | + "required": [ |
| 195 | + "type" |
| 196 | + ], |
| 197 | + "additionalProperties": false |
| 198 | +} |
| 199 | +``` |
| 200 | + |
| 201 | +</Accordion> |
0 commit comments