Do I need to have two .yml files? One defining each? Seems not cool to repeat all the steps
After a period of research, I personally recommend you better use two .yml
files with different build pipelines.
The most direct question is that the code on the master
branch and development
branch is not synchronized in real time. When the code on the two branches is different, the results of the build are different. If they are in the same pipeline, we need to manually check which branch the error came from when the build failed. This is a painful thing.
Another deep problem is that we could defined the CI trigger
and Scheduled trigger
in one yaml file, like:
trigger:
branches:
include:
- master
schedules:
- cron: "* 10 * * *"
always: true
displayName: Daily midnight build (UTC 22:00)
branches:
include:
- Development
To achieve this, we need set this yaml on the Development
branch. If we change any code in the master branch, it will trigger this pipeline. However, it only build the code on the Development
branch, it does not include the changed code in the master. So this CI trigger will be meaningless.
should I have different version of the same file in each branch? Won´t
this get merged at some point?
Personally recommend you better use different yaml files with different name. Just like you said, the same files are prone to unnecessary risks in later branch merge.
My bonus question was more like: Are you suppose to keep different
version of your build pipeline in different branches? I mean if i want
to build develop branch each time i push to develop can this trigger
be defined in the master branch version of the yaml file?
The answer is yes. You could set the CI triggers with a simple syntax in the master branch version of the yaml file:
trigger:
branches:
include:
- master
- Development
With this settings, every time you push to develop branch will trigger a build defined in the master branch version of the yaml file.
Note: For your bonus question, if we set above CI triggers, the pipeline will trigger a build due to continuous commits on the dev
branch. Sometimes we just modify a readme file, we do not want such modification to trigger unnecessary builds, the best way to solve such problems is to use PR trigger.
Hope this helps.