We want to add the following snippet before inheriting from an immutable YAML that does the build job.
jobs:
- job: PreBuild
timeoutInMinutes: 120
pool:
name: 'poolname'
vmImage: 'windows'
steps:
- checkout: self
clean: true
persistCredentials: true
- task: ..........
......
- task: ..........
......
But when we add the snippet before the extends
, the YAML would prompt: Unexpected value 'extends'
extends:
template: template.yml@TemplateRepo
So what is the best solution based on the immutable build templates to have us run several tasks before inheriting the template where template jobs always execute first? Or, are there any other approaches that we could have everything inheriting inside the template but have our custom steps run first?
The general approach is to negotiate with the owner of the "immutable" template to mutate it slightly in order to accept a stepList
, jobList
, or stageList
parameter (depending on your requirements). It's common to have, for example, optional preBuildSteps
and postBuildSteps
parameters that accept a stepList
in order to pass in steps that run before and after a build.
If it's truly immutable inasmuch as the team that owns the template will not implement such a pattern, then you won't be able to extend
the template and still fulfill your requirements.