Commit 8fe7817e authored by Achilleas Pipinellis's avatar Achilleas Pipinellis

More Bitbucket integration refactoring

parent 2fb28ddd
# Integrate your GitLab server with Bitbucket # Integrate your GitLab server with Bitbucket
Import projects from Bitbucket and login to your GitLab instance with your Import projects from Bitbucket.org and login to your GitLab instance with your
Bitbucket account. Bitbucket.org account.
## Overview ## Overview
You can set up Bitbucket as an OAuth provider so that you can use your You can set up Bitbucket.org as an OAuth provider so that you can use your
credentials to authenticate into GitLab or import your projects from Bitbucket. credentials to authenticate into GitLab or import your projects from
Bitbucket.org.
- To use Bitbucket as an OmniAuth provider, follow the [Bitbucket OmniAuth - To use Bitbucket.org as an OmniAuth provider, follow the [Bitbucket OmniAuth
provider](#bitbucket-omniauth-provider) section. provider](#bitbucket-omniauth-provider) section.
- To import projects from Bitbucket, follow both the - To import projects from Bitbucket, follow both the
[Bitbucket OmniAuth provider](#bitbucket-omniauth-provider) and [Bitbucket OmniAuth provider](#bitbucket-omniauth-provider) and
...@@ -21,16 +22,16 @@ Make sure to first follow the [Initial OmniAuth configuration][init-oauth] ...@@ -21,16 +22,16 @@ Make sure to first follow the [Initial OmniAuth configuration][init-oauth]
before proceeding with setting up the Bitbucket integration. before proceeding with setting up the Bitbucket integration.
To enable the Bitbucket OmniAuth provider you must register your application To enable the Bitbucket OmniAuth provider you must register your application
with Bitbucket. Bitbucket will generate an application ID and secret key for with Bitbucket.org. Bitbucket will generate an application ID and secret key for
you to use. you to use.
1. Sign in to Bitbucket. 1. Sign in to [Bitbucket.org](https://bitbucket.org).
1. Navigate to your individual user settings (Manage account) or a team's 1. Navigate to your individual user settings (**Bitbucket settings**) or a team's
settings (Manage team), depending on how you want the application registered. settings (**Manage team**), depending on how you want the application registered.
It does not matter if the application is registered as an individual or a It does not matter if the application is registered as an individual or a
team - that is entirely up to you. team, that is entirely up to you.
1. Select "OAuth" in the left menu. 1. Select **OAuth** in the left menu under "Access Management".
1. Select "Add consumer". 1. Select **Add consumer**.
1. Provide the required details: 1. Provide the required details:
| Item | Description | | Item | Description |
...@@ -40,66 +41,74 @@ you to use. ...@@ -40,66 +41,74 @@ you to use.
| **Callback URL** | Leave blank. | | **Callback URL** | Leave blank. |
| **URL** | The URL to your GitLab installation, e.g., `https://gitlab.example.com`. | | **URL** | The URL to your GitLab installation, e.g., `https://gitlab.example.com`. |
1. Grant at least the following permissions: And grant at least the following permissions:
``` ```
Account: Email Account: Email
Repositories: Read Repositories: Read, Admin
``` ```
1. Select "Save". >**Note:**
1. Select your newly created OAuth consumer. It may seem a little odd to giving GitLab admin permissions to repositories,
1. You should now see a Key and Secret in the list of OAuth customers. but this is needed in order for GitLab to be able to clone the repositories.
Keep this page open as you continue configuration.
1. On your GitLab server, open the configuration file.
For omnibus package: ![Bitbucket OAuth settings page](img/bitbucket_oauth_settings_page.png)
```sh 1. Select **Save**.
sudo editor /etc/gitlab/gitlab.rb 1. Select your newly created OAuth consumer and you should now see a Key and
``` Secret in the list of OAuth customers. Keep this page open as you continue
the configuration.
For installations from source: ![Bitbucket OAuth key](img/bitbucket_oauth_keys.png)
```sh 1. On your GitLab server, open the configuration file:
cd /home/git/gitlab
sudo -u git -H editor config/gitlab.yml
``` ```
# For Omnibus packages
sudo editor /etc/gitlab/gitlab.rb
1. See [Initial OmniAuth Configuration](omniauth.md#initial-omniauth-configuration) for initial settings. # For installations from source
1. Add the provider configuration: sudo -u git -H editor /home/git/gitlab/config/gitlab.yml
```
1. Follow the [Initial OmniAuth Configuration](omniauth.md#initial-omniauth-configuration)
for initial settings.
1. Add the Bitbucket provider configuration:
For omnibus package: For Omnibus packages:
```ruby ```ruby
gitlab_rails['omniauth_providers'] = [ gitlab_rails['omniauth_providers'] = [
{ {
"name" => "bitbucket", "name" => "bitbucket",
"app_id" => "YOUR_KEY", "app_id" => "BITBUCKET_APP_KEY",
"app_secret" => "YOUR_APP_SECRET", "app_secret" => "BITBUCKET_APP_SECRET",
"url" => "https://bitbucket.org/" "url" => "https://bitbucket.org/"
} }
] ]
``` ```
For installation from source: For installations from source:
```yaml ```yaml
- { name: 'bitbucket', - { name: 'bitbucket',
app_id: 'YOUR_KEY', app_id: 'BITBUCKET_APP_KEY',
app_secret: 'YOUR_APP_SECRET' } app_secret: 'BITBUCKET_APP_SECRET' }
``` ```
1. Change 'YOUR_KEY' to the key from the Bitbucket application page from step 7. ---
1. Change 'YOUR_APP_SECRET' to the secret from the Bitbucket application page from step 7.
Where `BITBUCKET_APP_KEY` is the Key and `BITBUCKET_APP_SECRET` the Secret
from the Bitbucket application page.
1. Save the configuration file. 1. Save the configuration file.
1. Restart GitLab for the changes to take effect. 1. [Reconfigure][] or [restart GitLab][] for the changes to take effect if you
installed GitLab via Omnibus or from source respectively.
On the sign in page there should now be a Bitbucket icon below the regular sign On the sign in page there should now be a Bitbucket icon below the regular sign
in form. Click the icon to begin the authentication process. Bitbucket will ask in form. Click the icon to begin the authentication process. Bitbucket will ask
the user to sign in and authorize the GitLab application. If everything goes the user to sign in and authorize the GitLab application. If everything goes
well the user will be returned to GitLab and will be signed in. well, the user will be returned to GitLab and will be signed in.
## Bitbucket project import ## Bitbucket project import
...@@ -198,3 +207,5 @@ Special thanks to the writer behind the following article: ...@@ -198,3 +207,5 @@ Special thanks to the writer behind the following article:
[init-oauth]: omniauth.md#initial-omniauth-configuration [init-oauth]: omniauth.md#initial-omniauth-configuration
[bitbucket-docs]: https://confluence.atlassian.com/bitbucket/use-the-ssh-protocol-with-bitbucket-cloud-221449711.html#UsetheSSHprotocolwithBitbucketCloud-KnownhostorBitbucket%27spublickeyfingerprints [bitbucket-docs]: https://confluence.atlassian.com/bitbucket/use-the-ssh-protocol-with-bitbucket-cloud-221449711.html#UsetheSSHprotocolwithBitbucketCloud-KnownhostorBitbucket%27spublickeyfingerprints
[reconfigure]: ../administration/restart_gitlab.md#omnibus-gitlab-reconfigure
[restart GitLab]: ../administration/restart_gitlab.md#installations-from-source
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment