Bitbucket is a git-based source-control platform made by Atlassian that serves as an alternative to GitHub with free unlimited private repos.
Bitbucket Pipelines is Atlassian's cloud-based continuous integration server, built using pre-configured docker containers.
When using Octopus Deploy with BitBucket, BitBucket Pipelines will be responsible for:
- Checking for changes in source control.
- Compiling the code.
- Running unit tests.
- Creating NuGet packages for deployment.
Octopus Deploy will be used to take those NuGet packages and to push them to development, test and production environments.
If you're using the cloud offering of BitBucket Pipelines, your Octopus Server must be accessible over the Internet.
BitBucket Pipelines environment variables
You can use environment variables in your Pipelines (available from the Settings ➜ Environment Variables menu of your BitBucket repository), which is a great place to store sensitive information such as your Octopus Deploy API keys (which is ideally not something you store in your source control).
|OCTOPUS_SERVER||The Octopus Server URL you wish to push the final package to|
|OCTOPUS_APIKEY||The Octopus Deploy API Key required for authentication|
BitBucket pack and push configuration
When you enable BitBucket Pipelines for your repository, BitBucket stores all the information it requires into a
bitbucket-pipelines.yml file in the base of your repository. This is the file we need to modify to run our build, pack and/or push package commands.
Example of packing and pushing
To show the basics working, here's an example pipeline step using the Octo.exe docker container which packs the current state of your repository into a zip file and then pushes that package to Octopus Deploy.
pipelines: default: - step: name: Deploy to Octopus image: octopusdeploy/octo:6.17.3-alpine script: - export VERSION=1.0.$BITBUCKET_BUILD_NUMBER - octo pack --id $BITBUCKET_REPO_SLUG --version $VERSION --outFolder ./out --format zip - octo push --package ./out/$BITBUCKET_REPO_SLUG.$VERSION.zip --server $OCTOPUS_SERVER --apiKey $OCTOPUS_APIKEY
For more in-depth information about using BitBucket Pipelines, we would recommend checking out their feature documentation.
Need support? We're here to help.