What are pipes?
Pipes provide a simple way to configure a pipeline and are powerful when you want to work with third-party tools.
Pipes are pre-built actions designed to simplify pipeline configuration. They provide a straightforward way to integrate third-party tools and services into your CI/CD workflow.
The simplest way to configure your pipeline is to use pipes. You just paste the pipe, supply a few key pieces of information, and the rest is done for you.
Simplicity: No need to write complex scripts for common tasks
Reliability: Pre-built and tested by the community or vendors
Consistency: Standardized way to integrate services
Maintenance: Updates handled by pipe maintainers
Speed: Get integrations working quickly
Pipes are used in your bitbucket-pipelines.yml file using the pipe keyword:
pipelines:
default:
- step:
script:
- pipe: atlassian/aws-s3-deploy:1.1.0
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: 'us-east-1'
S3_BUCKET: 'my-bucket'
LOCAL_PATH: 'dist'Deploy static files to Amazon S3:
- step:
name: Deploy to S3
script:
- npm run build
- pipe: atlassian/aws-s3-deploy:1.1.0
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: 'us-west-2'
S3_BUCKET: 'my-website-bucket'
LOCAL_PATH: 'dist'- step:
name: Deploy to Elastic Beanstalk
script:
- pipe: atlassian/aws-elasticbeanstalk-deploy:1.0.0
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: 'us-east-1'
APPLICATION_NAME: 'my-app'
ENVIRONMENT_NAME: 'production'
ZIP_FILE: 'application.zip'- step:
name: Deploy Lambda Function
script:
- pipe: atlassian/aws-lambda-deploy:1.2.0
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: 'us-east-1'
FUNCTION_NAME: 'my-function'
ZIP_FILE: 'function.zip'- step:
name: Deploy to ECS
script:
- pipe: atlassian/aws-ecs-deploy:1.6.0
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: 'us-east-1'
CLUSTER_NAME: 'my-cluster'
SERVICE_NAME: 'my-service'
TASK_DEFINITION: 'my-task'- step:
name: Deploy to Azure
script:
- pipe: microsoft/azure-web-apps-deploy:1.0.0
variables:
AZURE_APP_ID: $AZURE_APP_ID
AZURE_PASSWORD: $AZURE_PASSWORD
AZURE_TENANT_ID: $AZURE_TENANT_ID
AZURE_RESOURCE_GROUP: 'my-resource-group'
AZURE_APP_NAME: 'my-web-app'- step:
name: Deploy to Cloud Run
script:
- pipe: atlassian/google-cloud-run-deploy:1.0.0
variables:
KEY_FILE: $GCP_KEY_FILE
PROJECT: 'my-project'
SERVICE: 'my-service'
REGION: 'us-central1'
IMAGE: 'gcr.io/my-project/my-image:latest'- step:
name: Deploy to App Engine
script:
- pipe: atlassian/google-app-engine-deploy:1.0.0
variables:
KEY_FILE: $GCP_KEY_FILE
PROJECT: 'my-project'- step:
name: Deploy to Kubernetes
script:
- pipe: atlassian/kubectl-run:3.2.0
variables:
KUBE_CONFIG: $KUBE_CONFIG
KUBECTL_COMMAND: 'apply'
RESOURCE_PATH: 'k8s/deployment.yaml'- step:
name: Build and Push Docker Image
script:
- pipe: atlassian/docker-build-push:0.1.0
variables:
DOCKER_HUB_USERNAME: $DOCKER_HUB_USERNAME
DOCKER_HUB_PASSWORD: $DOCKER_HUB_PASSWORD
IMAGE_NAME: 'mycompany/myapp'
TAGS: '$BITBUCKET_BUILD_NUMBER latest'- step:
name: Notify Slack
script:
- npm test
- pipe: atlassian/slack-notify:2.0.0
variables:
WEBHOOK_URL: $SLACK_WEBHOOK_URL
MESSAGE: 'Build $BITBUCKET_BUILD_NUMBER completed successfully!'- step:
name: Security Scan
script:
- pipe: snyk/snyk-scan:1.0.0
variables:
SNYK_TOKEN: $SNYK_TOKEN
LANGUAGE: 'node'- step:
name: Code Quality Analysis
script:
- pipe: sonarsource/sonarcloud-scan:1.4.0
variables:
SONAR_TOKEN: $SONAR_TOKEN
SONAR_SCANNER_OPTS: '-Dsonar.projectKey=my-project'- step:
name: Send Email
script:
- pipe: atlassian/email-notify:0.5.0
variables:
USERNAME: $EMAIL_USERNAME
PASSWORD: $EMAIL_PASSWORD
FROM: 'builds@company.com'
TO: 'team@company.com'
SUBJECT: 'Build $BITBUCKET_BUILD_NUMBER'
BODY: 'Build completed successfully'- pipe: vendor/pipe-name:version
variables:
VARIABLE_NAME: 'value'
ANOTHER_VARIABLE: $SECURED_VARIABLEEnable debug output for troubleshooting:
- pipe: atlassian/aws-s3-deploy:1.1.0
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
S3_BUCKET: 'my-bucket'
LOCAL_PATH: 'dist'
DEBUG: 'true'pipelines:
default:
- step:
name: Build, Deploy, and Notify
script:
- npm run build
- pipe: atlassian/aws-s3-deploy:1.1.0
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
S3_BUCKET: 'my-bucket'
LOCAL_PATH: 'dist'
- pipe: atlassian/slack-notify:2.0.0
variables:
WEBHOOK_URL: $SLACK_WEBHOOK_URL
MESSAGE: 'Deployed to S3 successfully!'Run pipes based on conditions:
pipelines:
branches:
main:
- step:
script:
- npm run build
- pipe: atlassian/aws-s3-deploy:1.1.0
variables:
S3_BUCKET: 'production-bucket'
LOCAL_PATH: 'dist'
develop:
- step:
script:
- npm run build
- pipe: atlassian/aws-s3-deploy:1.1.0
variables:
S3_BUCKET: 'staging-bucket'
LOCAL_PATH: 'dist'You can create your own pipes to share common functionality across pipelines.
A pipe is essentially a Docker container with a specific interface:
FROM alpine:3.14
COPY pipe.sh /pipe.sh
RUN chmod +x /pipe.sh
ENTRYPOINT ["/pipe.sh"]pipe.sh:
#!/bin/bash
set -e
# Read pipe variables
API_URL=${API_URL:?'API_URL variable missing.'}
API_KEY=${API_KEY:?'API_KEY variable missing.'}
# Perform action
curl -X POST "$API_URL" \
-H "Authorization: Bearer $API_KEY" \
-d '{"status": "deployed"}'
echo "Notification sent successfully!"- pipe: mycompany/custom-notify-pipe:1.0.0
variables:
API_URL: 'https://api.example.com/notify'
API_KEY: $API_KEYBrowse available pipes at:
Bitbucket UI: Repository → Pipelines → Pipes
Atlassian Marketplace: Search for "Bitbucket Pipes"
Atlassian: AWS, Azure, GCP integrations
Microsoft: Azure services
Snyk: Security scanning
SonarSource: Code quality
HashiCorp: Terraform, Vault
Pin versions: Always specify exact pipe versions for reproducibility
Use secured variables: Store sensitive data as secured variables
Check documentation: Read pipe documentation for available options
Test in staging: Verify pipe configuration before production
Monitor pipe updates: Keep track of new versions and features
Cache pipe images: Pipes are Docker images and benefit from caching
Handle failures: Add error handling for pipe failures
Use debug mode: Enable DEBUG for troubleshooting
Ensure you're using the correct pipe name and version:
# Correct
- pipe: atlassian/aws-s3-deploy:1.1.0
# Incorrect
- pipe: aws-s3-deploy:latestCheck that all required variables are provided:
- pipe: atlassian/aws-s3-deploy:1.1.0
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID # Required
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY # Required
S3_BUCKET: 'my-bucket' # Required
LOCAL_PATH: 'dist' # RequiredVerify credentials are correct and have necessary permissions:
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID # Check in repository settings
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY # Ensure securedConfigure Variables for pipe credentials
Set up Deployments with deployment pipes
Learn about Docker Images to create custom pipes
Explore Service Containers for testing
What are pipes?
Pipes provide a simple way to configure a pipeline and are powerful when you want to work with third-party tools.
Write a pipe for Bitbucket Pipelines
Write a simple pipe or a complete pipe depending on how much detail and configuration you want to add.
Advanced techniques for writing pipes
Learn best practices to avoid unexpected results that come from passing variables between lots of different systems.
Was this helpful?