PageRenderTime 48ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/doc/integration/bitbucket.md

https://gitlab.com/tbeadle/gitlab-ce
Markdown | 138 lines | 105 code | 33 blank | 0 comment | 0 complexity | 8471ec5a36daa4144cc00aa5cc206d43 MD5 | raw file
  1. # Integrate your GitLab server with Bitbucket
  2. NOTE: **Note:**
  3. You need to [enable OmniAuth](omniauth.md) in order to use this.
  4. Import projects from Bitbucket.org and login to your GitLab instance with your
  5. Bitbucket.org account.
  6. ## Overview
  7. You can set up Bitbucket.org as an OAuth2 provider so that you can use your
  8. credentials to authenticate into GitLab or import your projects from
  9. Bitbucket.org.
  10. - To use Bitbucket.org as an OmniAuth provider, follow the [Bitbucket OmniAuth
  11. provider](#bitbucket-omniauth-provider) section.
  12. - To import projects from Bitbucket, follow both the
  13. [Bitbucket OmniAuth provider](#bitbucket-omniauth-provider) and
  14. [Bitbucket project import](#bitbucket-project-import) sections.
  15. ## Bitbucket OmniAuth provider
  16. > **Note:**
  17. GitLab 8.15 significantly simplified the way to integrate Bitbucket.org with
  18. GitLab. You are encouraged to upgrade your GitLab instance if you haven't done so
  19. already. If you're using GitLab 8.14 or below, [use the previous integration
  20. docs][bb-old].
  21. To enable the Bitbucket OmniAuth provider you must register your application
  22. with Bitbucket.org. Bitbucket will generate an application ID and secret key for
  23. you to use.
  24. 1. Sign in to [Bitbucket.org](https://bitbucket.org).
  25. 1. Navigate to your individual user settings (**Bitbucket settings**) or a team's
  26. settings (**Manage team**), depending on how you want the application registered.
  27. It does not matter if the application is registered as an individual or a
  28. team, that is entirely up to you.
  29. 1. Select **OAuth** in the left menu under "Access Management".
  30. 1. Select **Add consumer**.
  31. 1. Provide the required details:
  32. | Item | Description |
  33. | :--- | :---------- |
  34. | **Name** | This can be anything. Consider something like `<Organization>'s GitLab` or `<Your Name>'s GitLab` or something else descriptive. |
  35. | **Application description** | Fill this in if you wish. |
  36. | **Callback URL** | The URL to your GitLab installation, e.g., `https://gitlab.example.com`. |
  37. | **URL** | The URL to your GitLab installation, e.g., `https://gitlab.example.com`. |
  38. NOTE: Starting in GitLab 8.15, you MUST specify a callback URL, or you will
  39. see an "Invalid redirect_uri" message. For more details, see [the
  40. Bitbucket documentation](https://confluence.atlassian.com/bitbucket/oauth-faq-338365710.html).
  41. And grant at least the following permissions:
  42. ```
  43. Account: Email, Read
  44. Repositories: Read
  45. Pull Requests: Read
  46. Issues: Read
  47. Wiki: Read and Write
  48. ```
  49. ![Bitbucket OAuth settings page](img/bitbucket_oauth_settings_page.png)
  50. 1. Select **Save**.
  51. 1. Select your newly created OAuth consumer and you should now see a Key and
  52. Secret in the list of OAuth consumers. Keep this page open as you continue
  53. the configuration.
  54. ![Bitbucket OAuth key](img/bitbucket_oauth_keys.png)
  55. 1. On your GitLab server, open the configuration file:
  56. ```
  57. # For Omnibus packages
  58. sudo editor /etc/gitlab/gitlab.rb
  59. # For installations from source
  60. sudo -u git -H editor /home/git/gitlab/config/gitlab.yml
  61. ```
  62. 1. Add the Bitbucket provider configuration:
  63. For Omnibus packages:
  64. ```ruby
  65. gitlab_rails['omniauth_enabled'] = true
  66. gitlab_rails['omniauth_providers'] = [
  67. {
  68. "name" => "bitbucket",
  69. "app_id" => "BITBUCKET_APP_KEY",
  70. "app_secret" => "BITBUCKET_APP_SECRET",
  71. "url" => "https://bitbucket.org/"
  72. }
  73. ]
  74. ```
  75. For installations from source:
  76. ```yaml
  77. omniauth:
  78. enabled: true
  79. providers:
  80. - { name: 'bitbucket',
  81. app_id: 'BITBUCKET_APP_KEY',
  82. app_secret: 'BITBUCKET_APP_SECRET',
  83. url: 'https://bitbucket.org/' }
  84. ```
  85. ---
  86. Where `BITBUCKET_APP_KEY` is the Key and `BITBUCKET_APP_SECRET` the Secret
  87. from the Bitbucket application page.
  88. 1. Save the configuration file.
  89. 1. For the changes to take effect, [reconfigure GitLab][] if you installed via
  90. Omnibus, or [restart][] if installed from source.
  91. On the sign in page there should now be a Bitbucket icon below the regular sign
  92. in form. Click the icon to begin the authentication process. Bitbucket will ask
  93. the user to sign in and authorize the GitLab application. If everything goes
  94. well, the user will be returned to GitLab and will be signed in.
  95. ## Bitbucket project import
  96. Once the above configuration is set up, you can use Bitbucket to sign into
  97. GitLab and [start importing your projects][bb-import].
  98. If you want to import projects from Bitbucket, but don't want to enable signing in,
  99. you can [disable Sign-Ins in the admin panel](omniauth.md#enable-or-disable-sign-in-with-an-omniauth-provider-without-disabling-import-sources).
  100. [init-oauth]: omniauth.md#initial-omniauth-configuration
  101. [bb-import]: ../workflow/importing/import_projects_from_bitbucket.md
  102. [bb-old]: https://gitlab.com/gitlab-org/gitlab-ce/blob/8-14-stable/doc/integration/bitbucket.md
  103. [bitbucket-docs]: https://confluence.atlassian.com/bitbucket/use-the-ssh-protocol-with-bitbucket-cloud-221449711.html#UsetheSSHprotocolwithBitbucketCloud-KnownhostorBitbucket%27spublickeyfingerprints
  104. [reconfigure GitLab]: ../administration/restart_gitlab.md#omnibus-gitlab-reconfigure
  105. [restart]: ../administration/restart_gitlab.md#installations-from-source