microsoft / bedrock

Automation for Production Kubernetes Clusters with a GitOps Workflow
MIT License
129 stars 12 forks source link

azure pipeline build triggers do not work as specified by documentation #1170

Open mtarng opened 4 years ago

mtarng commented 4 years ago

Topic: The current assumption of: "A service's build pipeline definition (its build-update-hld.yaml file) only needs to exist in a single branch and can be configured to trigger off any branch." is incorrect.

According to documentation:

Pipelines are not associated with a branch. They are associated with the repositories they build, and with the location of the YAML file relative to the root of that repository. However, every time a pipeline runs, it uses the YAML file and the content from a specific branch. That branch is determined based on where the change is pushed to (in the case of CI builds), where the PR is targeted to (in the case of PR builds), or what you manually specify (in the case of manual runs). Each branch's YAML file independently determines whether the pipeline should be scheduled for that branch.

Additionally for "CI Triggers", which are being used for build pipelines:

For CI triggers, the YAML file that is in the branch you are pushing is evaluated to see if a CI build should be run.

This means:

  1. A service's build pipeline definition (its build-update-hld.yaml file) needs to exist in every ring branch and needs to be configured to trigger off of the ring's branch.
  2. When adding a ring, the associated branch for the ring also needs to have the build pipeline definition.
  3. Builds could vary between rings for a single service if the pipeline definitions are modified for a ring.
  4. Whichever branch (usually master, but could be another if using GitFlow) the source-of-truth bedrock.yaml file exists for a project, there needs to be the lifecycle pipeline definition file (lifecycle-pipeline.yaml) in the same branch, configured to trigger off of that branch.

Additional docs on CI triggers: https://docs.microsoft.com/en-us/azure/devops/pipelines/build/triggers?view=azure-devops&tabs=yaml#ci-triggers

Discussion that linked docs: https://github.com/MicrosoftDocs/vsts-docs/issues/2394#issuecomment-500559993

Question: How should spk enforce and document this behavior?

Deniall commented 4 years ago

You're correct. When you click 'Run pipeline', it won't even give the option to run the pipeline on any branches that don't have a pipeline.yaml in them. This kinda sucks, there's a serious amount of duplication and a lot of possibility of drift and overhead if the pipeline needs to be changed.