Bitbucket: Recursos e Funcionalidades EspecÃficas
Pipelines
Configuração Básica
# bitbucket-pipelines.yml
image: node:16
pipelines:
default:
- step:
name: Build and Test
caches:
- node
script:
- npm install
- npm test
artifacts:
- dist/**
Pipeline Avançada
pipelines:
branches:
main:
- step:
name: Build
script:
- npm install
- npm run build
- step:
name: Test
script:
- npm test
- step:
name: Deploy to Production
deployment: production
script:
- pipe: atlassian/aws-elasticbeanstalk-deploy
Integração Jira
Smart Commits
# Formato
git commit -m "PROJ-123 #time 2h #comment Implementando feature"
Workflow Integration
Confluence Integration
Documentação Automática
# Template de Página
{code:title=Exemplo|language=java}
public class Example {
// Código aqui
}
{code}
{status:colour=Green|title=Build Status}
Passed
{status}
Code Snippets
# Macro de código
{bitbucket:repo=project/repo|file=src/main.js|lines=10-20}
Segurança
Access Management
Branch Restrictions
+------------------------+
| PROTEÇÕES |
| |
| • Merge Check |
| • Build Status |
| • Approvals |
| • Branch Pattern |
+------------------------+
Code Insights
SonarQube Integration
definitions:
services:
sonar:
image: sonarqube:latest
pipelines:
default:
- step:
services:
- sonar
script:
- sonar-scanner
Code Coverage
- step:
name: Code Coverage
script:
- npm run coverage
after-script:
- pipe: atlassian/bitbucket-upload-coverage
variables:
COVERAGE_REPORTS: 'coverage/lcov.info'
Deployment
Environments
deployments:
staging:
- step:
script:
- aws deploy create-deployment
production:
- step:
trigger: manual
script:
- aws deploy create-deployment
Deployment Variables
# Configuração de variáveis
bitbucket pipelines variables add \
--key AWS_ACCESS_KEY_ID \
--value $ACCESS_KEY \
--secured
Webhooks e API
Webhook Configuration
{
"url": "https://api.example.com/webhook",
"events": [
"repo:push",
"pullrequest:created",
"pullrequest:merged"
]
}
API Usage
from atlassian import Bitbucket
bitbucket = Bitbucket(
url='https://bitbucket.org',
username='admin',
password='admin'
)
# Get repository info
repo = bitbucket.get_repo('project', 'repository')
Backup e Manutenção
Backup Strategy
Maintenance Scripts
#!/bin/bash
# Backup script
for repo in $(bitbucket repos list); do
git clone --mirror $repo
tar czf "${repo}.tar.gz" "${repo}.git"
done
Monitoramento
Status Page
Performance Metrics
+------------------------+
| MÉTRICAS |
| |
| • Response Time |
| • Build Time |
| • Success Rate |
| • Error Rate |
+------------------------+
Próximos Passos
Recursos Adicionais
22 abril 2025