-
Notifications
You must be signed in to change notification settings - Fork 345
CML with Bitbucket Cloud
CML now works with Bitbucket Cloud! Here, we'll show you how.
In Bitbucket Cloud, you can use the Bitbucket Pipelines CI/CD system to run workflows automatically on triggering events. When your workflow includes a CML report, you'll see it appear as a comment on the corresponding commit- like the report below:

The key file in any Bitbucket Pipeline project is bitbucket-pipelines.yml
. For example, to generate the report pictured above, your bitbucket-pipelines.yml
file should look like this:
image: dvcorg/cml-py3:latest
pipelines:
default:
- step:
name: Train model
script:
- pip install -r requirements.txt
- python train.py
# Print metrics
- cat metrics.txt > report.md
- echo >> report.md
# Add image
- cml-publish confusion_matrix.png --md >> report.md
# Send comment
- cml-send-comment report.md
To see this CML report in context, check out our project repo.
You'll need to create a variable called repo_token
so CML can authenticate with the Bitbucket Cloud API. Because the API requires a username and password, you have two options:
- Use the access credentials from a user on your team (note that you may also consider using Bitbucket Cloud App Passwords to generate a password just for CML, if you would prefer).
- Create a designated "CI/CD" account to author CML reports.
Whichever you choose, the steps to create your repo_token
will be the same:
- Use a Base64 encoder of your choice to encode your username and password:
printf $USERNAME:$PASSWORD | base64
. Copy the resulting token. - In your repository, go to Repository Settings -> Repository Variables.
- In the field "Name", enter
repo_token
. - In the field "Value", enter your Base64 transformed string.
- Check
Secured
to ensure that your credentials are hidden in all Bitbucket Pipelines logs.
At this time, Bitbucket Pipelines do not support self-hosted runners. Please see their official docs to learn more about pricing options if you have significant computing needs.
Check out our sample CML project repository in Bitbucket Cloud.