Skip to content

bashong/bitbucket-pipe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🛠 Metadata Pipe

This tool validates and processes metadata JSON files for use in infrastructure pipelines such as Terraform. It can be run locally, inside Docker, or within Bitbucket Pipelines.


🧪 Local Testing (WSL/Linux)

1. Set the Environment Variables

export METADATA="$(cat <metadata_path> | jq -c)"
export PAGERDUTY_TOKEN=<your_pagerduty_token>
export ENVIRONMENT=<production|stage>

Replace <metadata_path> with the full path to your metadata.json.
ENVIRONMENT only accepts production or stage.


2. Install Requirements Using venv

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

3. Run the Script Manually

python app/pipe.py

4. Run the Container

docker build -t metadata-pipe --no-cache .

docker run --rm \
  -e PAGERDUTY_TOKEN="${PAGERDUTY_TOKEN}" \
  -e METADATA="${METADATA}" \
  -e ENVIRONMENT="${ENVIRONMENT}" \
  metadata-pipe

📦 Bitbucket Pipelines Usage

bitbucket-pipelines.yml Sample

image: python:3.10

pipelines:
  default:
    - step:
        name: Validate Metadata
        script:
          - pip install -r requirements.txt
          - python pipe.py

🔐 Required Bitbucket Repository Variables

Set these in Repository Settings → Repository Variables:

Variable Name Description
METADATA JSON string output from jq -c < metadata.json
PAGERDUTY_TOKEN Your PagerDuty API token
ENVIRONMENT Either production or stage

✅ Output

  • Shows validation results and environment checks.
  • If invalid, prints an error and exits.
  • If valid, prints: Successfully Validated!

📄 Example metadata.json

{
  "service_name": "app-user-service",
  "team": "backend",
  "description": "User service for account registration and profile",
  "alerting": {
    "pagerduty": "abc123"
  }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors