Skip to content

Migrate from Bitbucket

Last updated:

Codebahn imports Bitbucket Cloud repositories over Git: commits, branches, and tags, with full history. You can import once, or keep a read-only mirror in sync while you work on Bitbucket. Bitbucket Pipelines does not run on Codebahn, so pipelines need a rewrite (see CI workflows).

  • A Codebahn account on a paid plan, Solo or Crew (see getting started)
  • Access to the Bitbucket repositories you want to migrate
  • Git installed locally (for pointing your clone at the new remote afterward)
BitbucketCodebahn
Commits, branches, tagsImported
Pull requests and commentsNot imported
Issues and wikisNot imported
Pipelines and their variablesNot imported; see CI workflows
Workspace members and permissionsNot imported; invite your team

Merge open pull requests before the import, or open them again on Codebahn from the imported branches.

Public repositories need no token: leave the username and password empty. For private ones, create an API token, which covers every repository your Bitbucket account can read:

  1. In Bitbucket, open your profile menu > Account settings > Security

  2. Click Create and manage API tokens > Create API token with scopes. Git access requires a token with scopes

  3. Set a name and an expiry date, and click Next

  4. Select Bitbucket as the app, and click Next

  5. Search for read:repository:bitbucket, tick its checkbox, and click Next

  6. Click Create token and copy the value. It is shown once

On Codebahn you enter this token as a password. The username depends on the type of token:

TokenUsernamePassword
API tokenx-bitbucket-api-token-authThe token
Repository access tokenx-token-authThe token

A repository access token limits access to one repository. Create it in the repository’s settings, under Security > Access tokens, with Read under Repositories.

  1. Log in to Codebahn

  2. Click + > Import repository > Git

  3. In Clone URL, enter the HTTPS URL without a username: https://bitbucket.org/your-workspace/your-repo.git. The URL that Bitbucket’s Clone button gives you may contain your username before the @; remove it

  4. For a private repository, enter the username and password from the table above

  5. Leave This repository will be a mirror unchecked

  6. Choose the owner (your account or an organization) and confirm the repository name

  7. Click Import repository

After it completes, the Codebahn repository is independent from Bitbucket. Revoke the token when you have imported everything.

A mirror is a read-only copy that pulls from Bitbucket on a schedule. Your team keeps pushing to Bitbucket, and you switch one repository at a time.

Follow the steps in Option A, but check This repository will be a mirror. Then set how often it syncs:

  1. Go to Settings > Repository on the mirror repo

  2. Under Mirror Settings, set the interval. The default is eight hours and the minimum is ten minutes. Codebahn checks for due mirrors every ten minutes, so a sync can start up to ten minutes after the interval ends

  3. Click Save

You cannot push to a mirror, and CI does not run on it. Syncs stop when the token expires, so note its expiry date and enter a new token in Mirror Settings before then.

When you are ready to switch, stop pushing to Bitbucket, click Synchronize Now, and wait for the sync to finish. Then use Danger Zone > Convert to regular repository. The conversion is permanent, and later commits on Bitbucket will not arrive.

Repeat the import or mirror steps for each repository. One API token works for all of them.

Create an empty repository on Codebahn, then clone and push by hand:

Terminal window
git clone --bare https://bitbucket.org/your-workspace/your-repo.git
cd your-repo.git
git push --mirror git@codebahn.net:your-org/your-repo.git

Point your local clone at Codebahn:

Terminal window
git remote set-url origin git@codebahn.net:your-org/your-repo.git

Add your SSH key first under Settings > SSH / GPG Keys if you haven’t.

A starting map:

Bitbucket PipelinesActions
bitbucket-pipelines.yml.github/workflows/*.yml
defaulton: push with a branches filter. Plain on: push also runs on tags, which default does not
brancheson: push with branches
pull-requestson: pull_request
stepA job. Pipelines runs steps in order; Actions runs jobs in parallel unless you add needs
parallelJobs without needs between them
scriptsteps with run
after-scriptA step with if: always()
imagecontainer
cachesactions/cache
artifactsactions/upload-artifact / actions/download-artifact. Later Pipelines steps download artifacts automatically; Actions jobs must download them
servicesservices at job level
Variables and secured variablesVariables and secrets, entered again on Codebahn
PipesNo direct equivalent. Use an action or run

Pipelines clones the repository at the start of every step. Actions does not clone automatically: add actions/checkout to every job that needs the code.

GitHub’s Actions Importer converts Bitbucket Pipelines to GitHub workflows, and its dry-run command lets you preview the result. We have not tested its output on Codebahn. Port one pipeline at a time, starting with the simplest, and verify each before moving on. See set up CI for a working example and CI compatibility for what is supported.

“The URL contains credentials” The clone URL includes a username, such as https://you@bitbucket.org/.... Remove everything between https:// and bitbucket.org, and use the username and password fields.

The clone URL starts with https://ssh.bitbucket.org You pasted an SSH URL (Bitbucket uses ssh.bitbucket.org for SSH), and Codebahn converted it to HTTPS with the SSH hostname. Change ssh.bitbucket.org to bitbucket.org. Otherwise the import fails after about two minutes with “Failed to connect to ssh.bitbucket.org port 443”.

“Authentication failed” Bitbucket returns the same error for a wrong username, a wrong token, and a repository that does not exist. Check that:

  • the username matches the token type
  • the token was created with scopes, for the Bitbucket app, and has not expired
  • the workspace and repository in the URL are correct, and your Bitbucket account can read them
  • a public repository has empty username and password fields, because wrong credentials fail there too

If you use an app password, replace it with an API token; Atlassian has disabled app passwords.

Mirror syncs stopped The token probably expired or was revoked. Enter a new one in Settings > Repository > Mirror Settings.

What you import, you can take back out. Org Settings > Export produces a tar.gz with every repo’s full Git history plus issues, pull requests, labels, milestones, and releases.