|
| 1 | +--- |
| 2 | +title: Linking code from Azure Devops Server |
| 3 | +sidebarTitle: Azure Devops Server |
| 4 | +icon: https://www.svgrepo.com/show/448307/azure-devops.svg |
| 5 | +--- |
| 6 | + |
| 7 | +import AzureDevopsSchema from '/snippets/schemas/v3/azuredevops.schema.mdx' |
| 8 | + |
| 9 | +If you're not familiar with Sourcebot [connections](/docs/connections/overview), please read that overview first. |
| 10 | + |
| 11 | +## Examples |
| 12 | + |
| 13 | +<AccordionGroup> |
| 14 | + <Accordion title="Enable TFS path support"> |
| 15 | + This is required if you're using an older version of ADO Server which has `/tfs` in the repo paths. |
| 16 | + ```json |
| 17 | + { |
| 18 | + "type": "azuredevops", |
| 19 | + "useTfsPath": true |
| 20 | + "repos": [ |
| 21 | + "organizationName/projectName/repoName", |
| 22 | + "organizationName/projectName/repoName2 |
| 23 | + ] |
| 24 | + } |
| 25 | + ``` |
| 26 | + </Accordion> |
| 27 | + <Accordion title="Sync individual repos"> |
| 28 | + ```json |
| 29 | + { |
| 30 | + "type": "azuredevops", |
| 31 | + "repos": [ |
| 32 | + "organizationName/projectName/repoName", |
| 33 | + "organizationName/projectName/repoName2 |
| 34 | + ] |
| 35 | + } |
| 36 | + ``` |
| 37 | + </Accordion> |
| 38 | + <Accordion title="Sync all repos in a collection"> |
| 39 | + ```json |
| 40 | + { |
| 41 | + "type": "azuredevops", |
| 42 | + "orgs": [ |
| 43 | + "collectionName", |
| 44 | + "collectionName2" |
| 45 | + ] |
| 46 | + } |
| 47 | + ``` |
| 48 | + </Accordion> |
| 49 | + <Accordion title="Sync all repos in a project"> |
| 50 | + ```json |
| 51 | + { |
| 52 | + "type": "azuredevops", |
| 53 | + "projects": [ |
| 54 | + "collectionName/projectName", |
| 55 | + "collectionName/projectName2" |
| 56 | + ] |
| 57 | + } |
| 58 | + ``` |
| 59 | + </Accordion> |
| 60 | + <Accordion title="Exclude repos from syncing"> |
| 61 | + ```json |
| 62 | + { |
| 63 | + "type": "azuredevops", |
| 64 | + // Include all repos in my-org... |
| 65 | + "orgs": [ |
| 66 | + "my-org" |
| 67 | + ], |
| 68 | + // ...except: |
| 69 | + "exclude": { |
| 70 | + // repos that are disabled |
| 71 | + "disabled": true, |
| 72 | + // repos that match these glob patterns |
| 73 | + "repos": [ |
| 74 | + "reposToExclude*" |
| 75 | + ], |
| 76 | + // projects that match these glob patterns |
| 77 | + "projects": [ |
| 78 | + "projectstoExclude*" |
| 79 | + ] |
| 80 | + // repos less than the defined min OR larger than the defined max |
| 81 | + "size": { |
| 82 | + // repos that are less than 1MB (in bytes)... |
| 83 | + "min": 1048576, |
| 84 | + // or repos greater than 100MB (in bytes) |
| 85 | + "max": 104857600 |
| 86 | + } |
| 87 | + } |
| 88 | + } |
| 89 | + ``` |
| 90 | + </Accordion> |
| 91 | +</AccordionGroup> |
| 92 | + |
| 93 | +## Authenticating with Azure Devops Server |
| 94 | + |
| 95 | +Azure Devops Server requires you to provide a PAT in order to index your repositories. To learn how to create PAT, check out the [Azure Devops docs](https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=Windows). |
| 96 | +Sourcebot needs the `Read` access for the `Code` scope in order to find and clone your repos. |
| 97 | + |
| 98 | +Next, provide the access token via the `token` property, either as an environment variable or a secret: |
| 99 | + |
| 100 | +<Tabs> |
| 101 | + <Tab title="Environment Variable"> |
| 102 | + |
| 103 | + 1. Add the `token` property to your connection config: |
| 104 | + ```json |
| 105 | + { |
| 106 | + "type": "azuredevops", |
| 107 | + "token": { |
| 108 | + // note: this env var can be named anything. It |
| 109 | + // doesn't need to be `ADO_TOKEN`. |
| 110 | + "env": "ADO_TOKEN" |
| 111 | + } |
| 112 | + // .. rest of config .. |
| 113 | + } |
| 114 | + ``` |
| 115 | + |
| 116 | + 2. Pass this environment variable each time you run Sourcebot: |
| 117 | + ```bash |
| 118 | + docker run \ |
| 119 | + -e ADO_TOKEN=<PAT> \ |
| 120 | + /* additional args */ \ |
| 121 | + ghcr.io/sourcebot-dev/sourcebot:latest |
| 122 | + ``` |
| 123 | + </Tab> |
| 124 | + |
| 125 | + <Tab title="Secret"> |
| 126 | + <Note>Secrets are only supported when [authentication](/docs/configuration/auth/overview) is enabled.</Note> |
| 127 | + |
| 128 | + 1. Navigate to **Secrets** in settings and create a new secret with your PAT: |
| 129 | + |
| 130 | +  |
| 131 | + |
| 132 | + 2. Add the `token` property to your connection config: |
| 133 | + |
| 134 | + ```json |
| 135 | + { |
| 136 | + "type": "azuredevops", |
| 137 | + "token": { |
| 138 | + "secret": "mysecret" |
| 139 | + } |
| 140 | + // .. rest of config .. |
| 141 | + } |
| 142 | + ``` |
| 143 | + |
| 144 | + </Tab> |
| 145 | +</Tabs> |
| 146 | + |
| 147 | +## Schema reference |
| 148 | + |
| 149 | +<Accordion title="Reference"> |
| 150 | +[schemas/v3/azuredevops.json](https://github.com/sourcebot-dev/sourcebot/blob/main/schemas/v3/azuredevops.json) |
| 151 | + |
| 152 | +<AzureDevopsSchema /> |
| 153 | + |
| 154 | +</Accordion> |
0 commit comments