Coming from BitBucket: Workflows with different contexts

Hi,

I’m migrating from BitBucket Pipelines and hoping to find a CircleCI configuration sweet spot.

I have a pretty standard Test-Build-Deploy workflow, but depending on the source branch or tag need to set different contexts.

With BitBucket, filtering is at the pipeline (aka workflow) level, forcing us to create many versions of the essentially the same pipeline. I was hoping to avoid this situation entirely with Circle, but it actually looks worse: now I need to have all of the same mostly similar workflows AND I need to write filters at the jobs level to ensure they are mutually exclusive.

BitBucket also has a concept of a default pipeline, that will run if there are no more specific matches. I’m not sure how to achieve this with Circle in a straight forward way.

Thanks for any help making the transition.

Hi,

Besides having multiple workflows, you could also have a single workflow, and specify each variant of the same job in the same workflow, which would have different branch or tag filters. You might find this makes your config a little shorter. I would also recommend using YAML anchors to reduce repetition.

For example:

my_filters: &my_filters
  branches:
    ignore: /.*/
  tags:
    only: /^(major|minor|patch)-release-v\d+\.\d+\.\d+$/

...
workflows:
  my-workflow:
    jobs:
      - myjob:
          filters: *my_filters

Regarding having a default pipeline, this might be possible to simulate by using a regexp expression for the filter that excludes all the other filter patterns.

Thanks for this. Re:

With a single workflow, how would I set different contexts?

@jskrepnek As contexts are defined on a job-level, each variant of a job in the workflow can use a different context.