# Bitbucket Server

{% hint style="warning" %}
Only organization Admins can create, edit and delete integrations.
{% endhint %}

Link your model objects to reality, such as code repos, branches, folders and files. When those links move, change names or get deleted, we’ll notify you that the object may need to be updated in your IcePanel landscape.

Learn more here:  [Linking to reality](/integrations/linking-to-reality.md)

## Using BitBucket Server

### Setting up an access token

First, you must create an access token with read permissions in your Bitbucket instance.

1. Once logged in, in your profile menu click `Manage account`
2. Go to the `Access tokens` tab and click `Create token`
3. Fill in the token name and ensure the permissions are set to `Read`
4. Click `Create` and copy the token for the next step

### Setting up Bitbucket Server

1. From your landscape homepage, click on the organization dropdown at the top of the navigation bar
2. Click on the `Manage` link for the organization you want to setup
3. Go to the `Integrations` tab
4. Click on the `New Integration` button, then select `Bitbucket Server`
5. Enter your Bitbucket server URL which must be accessible to the IcePanel API ([api.icepanel.io](https://api.icepanel.io/))
6. Enter your Bitbucket username and the token you created in the previous step
7. Click `Link Bitbucket`

### Unlinking your Bitbucket Server

You can unlink the integration from IcePanel and Bitbucket Server.

1. From your landscape homepage, click on the organization dropdown at the top of the navigation bar
2. Click on the `Manage` link for the organization you want to setup
3. Go to the `Integrations` tab and Bitbucket Server tab
4. Click the `Remove` button
5. Login to Bitbucket, click `Manage account` in your profile menu
6. Go to the `Access tokens` tab and click `Revoke` next to the token you created in the previous steps

### Whitelist the IcePanel repo scanner

You may find that no code repos show if your organization has enabled IP filtering or whitelisting in your integration. To resolve this whitelist the IcePanel repo scanner IP address:

`34.168.47.236`

## CLI command reference

```
Usage: IcePanel bitbucket-server-sync [options]

Syncronize IcePanel code repos with a BitBucket server instance

Options:
  --api-url <value>          IcePanel API URL (default: "https://api.icepanel.io/v1")
  -k, --api-key <value>      IcePanel API key
  -s, --server-url <value>   BitBucket server URL
  -u, --username <value>     BitBucket server username
  -t, --token <value>        BitBucket server token
  -p, --project-key <value>  BitBucket project key, comma seperated
  -i, --interval <secs>      Interval for syncronization (default: "1800")
  -f, --force                Force refresh of code repos and trees
  --filter-repos <pattern>   Filter code repo names to include, supports wildcards
  --delete-all               Delete all code repos and trees for this integration
  --concurrency <value>      Number of jobs that can be processed in parallel (default: "10")
  -h, --help                 display help for command

Environment variables:
  API_URL                     IcePanel API URL
  API_KEY                     IcePanel API key
  BITBUCKET_SERVER_URL        BitBucket server URL
  BITBUCKET_SERVER_USERNAME   BitBucket server username
  BITBUCKET_SERVER_TOKEN      BitBucket server token
  BITBUCKET_PROJECT_KEY       BitBucket project key, comma seperated
  SYNC_INTERVAL               Interval for syncronization
  FORCE                       Force refresh of code repos and trees
  FILTER_REPOS                Filter code repo names to include, supports wildcards
  CONCURRENCY                 Number of jobs that can be processed in parallel
  LOG_LEVEL                   Options are fatal, error, warn, info, debug, trace, silent
  
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.icepanel.io/integrations/code-repo-linking/bitbucket-server.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
