1
votes

I have Azure DevOps custom extension which contain build task. I am trying to configure/edit YAML file in my codebase and add my custom build task into it via VS Code. I am using Microsoft VS Code extension docs-yaml extension to validate my YAML file.

As you can see in below image all build tasks, which are available in Microsoft Build template are validating successfully without any issue. But it failed to validate my build task sampletask@3. As I understood YAML file is getting validated against file called pipeline schema. I found this schema file in below location https://raw.githubusercontent.com/microsoft/azure-pipelines-vscode/v1.174.2/service-schema.json

  1. How to /is it possible to add my build task details into, pipeline schema file?
  2. If above is not possible, is there any way I can successfully validate my build task in VS Code?

Please refer below image. cannot validate my task

references :

1

1 Answers

3
votes

How to add and validate custom build task in Azure DevOps YAML File via VS Code

I could not reproduce this issue with the extension docs-yaml.

Then I test another commonly used extension Azure Pipelines, I could reproduce this issue as you. So I boldly assume that this verification should come from the extended Azure Pipelines. You could check if you have installed this extension in your Visual Studio code.

After installing that extension and restart the VS Code, I could see the verification info:

enter image description here

To resolve this, we could move on the document Azure Pipelines for VS Code

Out of the box, the extension has a generic schema file that includes only in-box tasks. You probably have custom tasks installed in your organization. To teach the extension about those, grab a copy of your schema and tell the extension where to find it.

  1. Visit https://dev.azure.com/YOU-ORG-HERE/_apis/distributedtask/yamlschema and save the output as my-schema.json.
  2. Edit your workspace's settings.json to include this: {
    "[azure-pipelines].customSchemaFile": "./path/to/my-schema.json" }
  3. Restart VS Code. The extension will now validate against your schema. It'll give you autocompletes for your custom tasks.

Detailed steps for the second step:

Click the gear button in the lower left corner of your VS code, Manage-> Settings, then click Workspace->Extensions->Azure pipeline:

enter image description here

enter image description here

I save the yamlschema.json file in the folder where the settings.json is.

After restarting the VS Code, I could successfully validate that build task in VS Code:

enter image description here