Hi All, I am new to BB pipeline. I wanted to create a pipeline for running lint for python followed by deploying to GCP CF. Have few questions on designing the pipeline as below.
BB branches: dev, test, release. Default branch is dev.
1] I want to understand when to use pipeline with default vs branches?
2] I want to run lint only when code is checked in dev branch. I want to run PyTest only when code is merged in test How do I design this in pipeline?
Here is a pipeline code I have created so far. Request your feedback. TIA!
image: python:3.11
pipelines:
# default:
# - step:
# caches:
# - pip
# name: "Check flake8"
# script: # Modify the commands below to build your repository.
# - pip install flake8
# - flake8 --max-line-length=180 --ignore=E203,W503
branches:
dev:
- step:
name: "Deploy to dev GCP project"
image: google/cloud-sdk:latest
# deployment: test
script:
- pip install flake8
- flake8 --max-line-length=180 --ignore=E203,W503
- echo $DEV_API_KEYFILE > ~/.gcloud-api-key.json
- gcloud auth activate-service-account --key-file ~/.gcloud-api-key.json
- gcloud functions deploy dev_bitbucket_linting --entry-point auth --runtime=python311 --timeout=240 --min-instances=1 --max-instances=10 --trigger-http --service-account=$DEV_SERVICE_ACCOUNT --region $DEV_GCP_REGION --project $DEV_GCP_PROJECT
test:
- step:
name: "Deploy to test GCP project"
script:
- pip install pytest
- pytest --junitxml=test-reports/report.xml
- echo $TEST_API_KEYFILE > ~/.gcloud-api-key.json
- gcloud auth activate-service-account --key-file ~/.gcloud-api-key.json
- gcloud functions deploy dev_bitbucket_linting --entry-point auth --runtime=python311 --timeout=240 --min-instances=1 --max-instances=10 --trigger-http --service-account=$TEST_SERVICE_ACCOUNT --region $TEST_GCP_REGION --project $TEST_GCP_PROJECT