No, this is not necessary. When you define a pipeline for already existing file you can select a branch:
You can even put a pipeline definition in a different repo and benefit from multiple repo pipeline to achieve this goal.
If you want to parameterized pipeline you should take a look at templates:
# File: templates/npm-with-params.yml
parameters:
- name: name # defaults for any parameters that aren't specified
default: ''
- name: vmImage
default: ''
jobs:
- job: ${{ parameters.name }}
pool:
vmImage: ${{ parameters.vmImage }}
steps:
- script: npm install
- script: npm test
And then you can use it in this way:
# File: azure-pipelines.yml
jobs:
- template: templates/npm-with-params.yml # Template reference
parameters:
name: Linux
vmImage: 'ubuntu-16.04'
- template: templates/npm-with-params.yml # Template reference
parameters:
name: macOS
vmImage: 'macOS-10.14'
- template: templates/npm-with-params.yml # Template reference
parameters:
name: Windows
vmImage: 'vs2017-win2016'
You can also use template froma different repo. Assuming you have common.yml template in Contoso/BuildTemplates repo:
# Repo: Contoso/LinuxProduct
# File: azure-pipelines.yml
resources:
repositories:
- repository: templates
type: github
name: Contoso/BuildTemplates
jobs:
- template: common.yml@templates # Template reference
EDIT:
And in terms of this question:
Additionally how can i achieve branch parameterized job in azure pipelines?
This is possible but not using built-in feature for getting repositories. What you need is use for instance powershell task and this command:
GIT clone -b <branch> https://<PAT>@dev.azure.com/Organization/My%20Project/_git/MyRepo
Please also put in your YAML also checkout: none
as we don't want to get source code by standard pipeline task.
In above command you must put PAT token. More about this you will find here