You have a project in Azure DevOps.
You create the following YAML template named Template1.yml.
steps:
- script: npm install
- script: yarn install
- script: npm run compile
You create the following pipeline named File1.yml.
parameters:
usersteps:
- task: MyTask@1
- script: echo Done
You need to ensure that Template1.yaml runs before File1.yml.
How should you update File1.yml?
Click on the arrows to vote for the correct answer
A. B. C. D.C
Azure Pipelines offers two kinds of templates: includes and extends. Included templates behave like #include in C++: it's as if you paste the template's code right into the outer file, which references it. To continue the C++ metaphor, extends templates are more like inheritance: the template provides the outer structure of the pipeline and a set of places where the template consumer can make targeted alterations.
Example:
extends:
template: template.yml@templates
parameters:
usersteps:
- script: echo This is my first step
- script: echo This is my second step
https://docs.microsoft.com/en-us/azure/devops/pipelines/security/templatesThe correct answer is B:
yamltemplate: template1.yml parameters: usersteps: - task: MyTask@1 - script: echo Done
Explanation:
In Azure DevOps, pipelines can be created using YAML, and YAML templates can be used to define reusable parts of a pipeline. In this scenario, the YAML template Template1.yml
defines a sequence of steps to be executed in the pipeline, and the pipeline File1.yml
contains a parameterized list of steps that need to be executed.
To ensure that Template1.yml
runs before File1.yml
, we need to include the reference to the template in the pipeline YAML file using the template
keyword, followed by the name of the YAML file that contains the template (template1.yml
). The parameters
keyword should then be used to specify the parameters required by the template, which in this case is the usersteps
parameter. The usersteps
parameter is an array that contains the steps to be executed after the steps defined in the template.
Option A is incorrect because extends
is not a valid keyword to include a YAML template in a pipeline. The correct keyword is template
.
Option C is incorrect because the extends
keyword is not used to include a YAML template in a pipeline, and there is a typo in the filename of the template (templatel.yml
instead of template1.yml
).
Option D is incorrect because the template
keyword is used inside the usersteps
parameter instead of being used directly in the pipeline YAML file. Additionally, there is a typo in the filename of the template (templatel.yml
instead of template1.yml
).