BitBucket
Step 1: Get your Safety API Key
Step 2: Set up a Bitbucket Pipeline on your repository (If you don't have one already)
Step 3: Configure your bitbucket-pipelines.yml YAML file to run Safety
# Safety Security Scans Template
# This template allows you to run security scans on your Python dependencies.
# The workflow allows running tests on the default branch.
image: python:3.12
pipelines:
default:
- parallel:
- step:
# Run Safety to scan your Python Environment (recommended and best practice)
name: Safety Security Scan on the Python Environment
script:
# Install Safety CLI - Safety's command-line tool
- pip install safety
# Install your Python dependencies as per usual.
# This example uses requirements.txt and pip, but you may use Poetry with its Pipfiles, or pipenv with its pyproject.toml file.
- pip install -r requirements.txt
# Run safety to scan the local Python environment. This will scan all installed dependencies, including any transitive dependncies that get installed during your installation
- safety --key $SAFETY_API_KEY --stage cicd scanFinal Step: Add your Safety API Key as a BitBucket repository variable
You're done!

Next Steps: Configure your Pipeline file, and learn more about Safety
Last updated
Was this helpful?


