CI/CD using Bitbucket Pipelines
Bitbucket Pipelines is a continuous integration and delivery (CI/CD) service built into Bitbucket, Atlassian's Git-based version control system. Pipelines allow developers to automatically build, test, and deploy their code every time they push changes to a Bitbucket repository.
Here are some key features of Bitbucket Pipelines:
Easy setup: Pipelines are built into Bitbucket, so it's easy to get started with no additional setup.
Flexible configuration: Pipelines can be configured using YAML files, allowing for high customization.
Docker support: Pipelines uses Docker containers to provide a consistent and isolated environment for running builds and tests.
Parallel builds: Pipelines can run multiple builds in parallel, which can help speed up the overall build process.
Deployment options: Pipelines can deploy your code to various platforms, including AWS, Google Cloud, and Azure.
Setup Bitbucket Pipelines for use with DuploCloud.
To use Pipelines, you need to:
Create a bitbucket-pipelines.yml
file in your repository's root
directory. This file contains the configuration for your builds and deployments.
Deploy the application with DuploCloud as a Service and test that it works as expected.
Bitbucket Pipelines are only recommended to be used for upgrades of container images and to run tests that can be written to run either before or after.
Configure BitBucket Pipelines for use with DuploCloud:
Create a repository variable for the DUPLO_TOKEN
. Set the variable at the project or workspace level or even in a deployment. Create service account users in DuploCloud by assigning a user name, such as bitbucket
. Ensure the user name is not an email to avoid confusion.
Retrieve a token for the user (bitbucket
) that you set up.
Use OpenID Connect (OIDC) by setting up an OpenID login with Bitbucket Pipelines.
After configuring the OIDC provider by using AWS IAM, the IAM role needs an associated trust relationship. For example:
Building images with Bitbucket Pipelines
When building Docker images, use pipelines as much as possible. This example assumes that you are using the default Atlassian builder image in this example.
To publish a new image to AWS Elastic Container Registry (ECR), for example, use the following sample code to publish a new image when the repo is tagged:
NOTE: OIDC is true
when OIDC Authentication is enabled.
Update images with DuploCloud's BitBucket Deploy Pipe
When your pipeline has updated an image, you'll push it to your deployed service. DuploCloud's custom Bitbucket Pipe does this, updating any service with the latest image.
For example, to update a Service (myservice
) for a Tenant (sometenant
) when a new Git tag is published (myimage:${BITBUCKET_TAG}
), use this code:
Learn more about .