Bitbucket
Bitbucket is a Git based code hosting and collaboration tool, built for teams. Bitbucket offers both on-premise and cloud editions. While BitBucket does have its own version of a CI/CD platform, it requires an organization's projects to be migrated to the Bitbucket's platform in order to use it.
BuildMaster is designed to work alongside Bitbucket to provide a self-managed CI/CD solution using BuildMaster's Git Integration.
Connecting to Bitbucket
BuildMaster's Git Integration allows you to connect to Bitbucket at application creation or through the application's settings page. To connect BuildMaster to Bitbucket:
- Either create a new application or add a new connection on the application settings page, then select Git Repository
- Select the BitBucket connection type
- Enter your BitBucket user name and http access token and click Select Bitbucket Repository
- Select your Bitbucket namespace and enter or select your repository and click Save Repository
The Bitbucket repository will then be synchronized to your server and you will see a successful synced message.
Editing a BitBucket Connection
You can edit these items directly to enable advanced scenarios (such as a shared repository) by clicking view all on the Settings page, or by going to Admin > Credentials & Resources. See Credentials & Resources to learn more.
Generating a Bitbucket HTTP Access Token
When connecting BuildMaster to Bitbucket, you need to use a Bitbucket HTTP Access Token. To generate this token:
- Navigate to your Bitbucket project or repository
- In the upper right corner, click your user icon, and then click Manage account
- Navigate to HTTP access tokens
- Click Create token
- Enter a token name select full control for the project and repository permissions
- Click Create
Browsing Bitbucket Repositories
After adding a synchronized Bitbucket repository to an application, you'll be able to browse that repository's branches, source code, and commits—as well as the changes between builds/releases—directly from BuildMaster's web UI. See our synchronized Git repositories documentation to learn more.
When viewing branch, tag, or commit details, you can also click the "browse on Bitbucket" link to view details in Bitbucket directly.
Bitbucket and Scripting
When your application uses a synchronized Bitbucket repository, you'll be able to create a build from any commit in the repository. When creating a build in this manner, the selected commit - along with its branch and repository - will be associated with that build and displayed throughout the UI. You can access those values in scripts with the $Commit
, $Branch
, and $Repository
variable functions. See Git Build Scripts & Automations for more information.
Bitbucket Git Operations
The Bitbucket integration supports most of the standard BuildMaster Git operations, but there are a couple things to keep in mind when using these operations. One operation that is not supported is the Git::Set-CommitStatus
operation. Bitbucket does not support Git commit statuses at this time.
Using Other Git Repositories
By default, Git::Checkout-Code
will use your Git Connection to connect to your repository. If you would like to select a repository that is different than what your Git connection specifies; navigate to your repository in Bitbucket, click the "Clone" button and copy the URL under Clone with HTTPS, then set the RepositoryUrl
parameter to it in theGit::Checkout-Code
operation.
In cases like this, you can specify input parameters like this.
Git::Checkout-Code
(
RepositoryUrl: https://bitbucket.org//inedo/ProfitCalcNet.git,
BranchOrCommit: master,
To: c:\build\space\src,
CommitHash => $CommitId
);
Log-Information Checked out at $CommitId from my-repo;
Git::Set-CommitStatus Operation
Git commit statuses are currently not supported in Bitbucket.
GitCreate-PullRequest and GitMerge-PullRequest
Just like Git::Checkout-Code
, the Git::Create-PullRequest
operation will use your Git Repository connection to create a pull request in Bitbucket. Here is an example of using a repository that is different than what your Git Repository connection specifies:
Git::Create-PullRequest
(
Title: My New Thing,
Target: main,
Repository: https://bitbucket.org//inedo/ProfitCalcNet.git
);
This operation will also record the ID of the Pull Request on the Build, so that you can later access it with $PullRequestId
.
The Feature Branch Workflow Pipeline will create a script with the Git::Create-PullRequest
operation. Try it out to see this in action.
You may want to extend your Feature Branch workflow and let BuildMaster do the merging.
To complete a merge request, you can run the operation without parameters:
Git::Merge-PullRequest;
This will use the $PullRequestId
if you don't specify it as a parameter.
Installing the Bitbucket Extension
The Bitbucket extension is installed by default when you install BuildMaster. You can upgrade the extension by navigating to the Admin > Extensions page in your instance of BuildMaster and clicking the update link to the right of the Bitbucket extension. Once the Bitbucket extension has been upgraded, it can be reverted back to the built-in version by navigating to Admin > Extensions > Bitbucket and then selecting the Change Version button in the upper right corner.
If your instance doesn't have Internet access, you can upgrade/downgrade it by manually installing the Bitbucket extension after downloading the Bitbucket Extension Package.
Built-in extensions cannot be deleted or downgraded past the included version.