Azure Pipeline: Error: Cannot read properties of undefined (reading ‘templatePath’).

This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Community Hub.

This blog content is compiled by @Ahetejaz from Azure DevOps CSS support team.

 

Recently, he helped a customer in resolving an issue 'Error: Cannot read properties of undefined (reading 'templatePath') in Azure DevOps Services when user tried to edit the YAML pipeline. The reason for the issue was deletion of service connection for external repository.

 

Scenario:

Azure DevOps YAML pipeline connected with Bitbucket using ‘Bitbucket cloud’ service connection.

The pipelines gives below error while editing it.

 

BlogImage.png

 

Findings:

When we select edit on the pipeline, the first thing is to connect the repository provider service, fetch the YAML and display it. In this scenario service connection is deleted. So, we are unable to connect to the Bitbucket cloud and fetch the YAML.

Recommendation:

There are two workarounds to mitigate the issue.

 

Workaround One:

 

Get the JSON body of the affected YAML pipeline using Rest API - Definitions - Get - REST API (Azure DevOps Build) | Microsoft Learn

 

Create a new service connection or use an existing service connection. Go to service connection page and select the service connection. From the URL you would get the resource id - https://dev.azure.com/{OrganizationName}/{ProjectName}/_settings/adminservices?resourceId=664e242d-dd2f-4201-8d03-4f5a64b8120c

 

Update the affected YAML pipeline using Rest API - Definitions - Update - REST API (Azure DevOps Build) | Microsoft Learn

 

The JSON body collected earlier needs to be modified in the update Rest API call. Search for "connectedServiceId" which is nothing but resource id of deleted service connection. Replace the same with resource id of new or existing service connection. Perform the update call.

 

Example change to be made in JSON body: "connectedServiceId":"664e242d-dd2f-4201-8d03-4f5a64b8120c"

 

Workaround Two: 

 

  1. Edit any working yaml pipeline in the project.
  2. Click on the context menu (3 dots) -> select "Triggers". 
  3. This opens the Classic editor of YAML. 
  4. Copy this URL and replay the definition ID (pipeline ID) of the non-working YAML pipeline. The url will be something like this "https://dev.azure.com/<<ORG-NAME>>/<<PROJECT-NAME>>/_apps/hub/ms.vss-ciworkflow.build-ci-hub?_a=edit-build-definition&id=<<ID>>&view=Tab_Triggers
  5. Change the service connection and save it.

 

Note: You can directly use the URL mentioned in point 4 and replace the highlighted items, to update the details. The steps as mentioned, so you know how to get the URL.

 

Cheers!!

Ahmad

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.