Import Azure DevOps repos into JSM Assets

Let's review the process in a summarized way. First, we need to register an app in Azure portal to allow iHub to connect to the Azure DevOps instance. This is done by adding an app and assigning the scopes that allow the connection to read resources like projects and repos. Then we need to enter the credentials from the app into iHub Credentials in an OAuth2 configuration and connect to the app. Once this is done, we can now read the resources from Azure DevOps. Now it is time to set up an asset import to push data to assets. This is done easiest by using the wizard and selecting a generic import. The generic import gives us the skeleton but will require modifications to adjust to the data we want to import. In the documentation, there is a template ready for that.

image-20241021-085336.png

Excalidraw — Collaborative whiteboarding made easy

  1. Open iHub Cloud

  2. Select Credentials

  3. Click Create and select OAuth and enter a name

  4. Copy the callback URL we will need that for the Azure app

 

  1. Goto https://portal.azure.com/ and login

  2. Click on App registrations

  3. Click on view API Permission

  4. Add the scope needed, we added these

     

Scope and rest doc https://learn.microsoft.com/en-us/rest/api/azure/devops/git/repositories/list?view=azure-devops-rest-7.1&tabs=HTTP#security

  1. Click Enterprise applications in the bottom

  2. Click the big blue button: Grant admin consent

  3. Click on Authentications menu.

  4. Click Add Platform and select Web

  5. Enter a redirect URL. Add the url to iHub as stated in the OAuth credential page.

     

  6. Click on Overview and click on the Endpoints this will display all endpoints needed for your instance

  7. Go to Certificates & secrets  and click on new Client secret to generate the client secret.

  8. Copy the VALUE and save it (it will only be shown one time)

  9. Click on Overview copy the Client ID

Go back to iHub Cloud and select Credential created in the first part

Credential name

Microsoft (devops)

Credential name

Microsoft (devops)

Authorization Url

https://login.microsoftonline.com/yourgroupid/oauth2/v2.0/authorize

Access Token Url

https://login.microsoftonline.com/yourgroupid/oauth2/v2.0/token

Client Id

Enter client id from the Overview page in Azure app

Client Secret

Paste the VALUE in the Client Secret box from the Azure Credentials

Scope (note space between the four scopes)

offline_access https://app.vssps.visualstudio.com/vso.code https://app.vssps.visualstudio.com/vso.project https://app.vssps.visualstudio.com/vso.profile

Include Scope

Yes

Make access token request with

x-www-form-urlencoded

Include State

Yes

Click the “Click here to Authorize” button to get the first access token.

  1. Click the three dots in next to the +Create Integration button.

  2. Select Wizard

  3. Select Jira Service Management

  4. Select Asset Generic API Import

  5. Follow the wizard and select the schema where the asset objects will be imported

  6. Open the Integration

  7. Select the Update Import Mapping

     

  8. Paste this mapping file into the body of “Update import mapping”

  9. Add a action called “Get Devops projects”

  10. Configure it to do a GET to https://dev.azure.com/rixterdev/_apis/projects?api-version=7.1 where rixterdev is the url to your devops instance.

  11. Update the Submit Data action to have this body

    { "data":{ "projects":{{{toJSON value}}} } }
  12. Create a action and place it under “Get Devops projects” call it “Get Repo for Project”

  13. Configure it to do a GET to https://dev.azure.com/rixterdev/{{payload.id}}/_apis/git/repositories?api-version=7.1 note the mustache payload syntax in the url

  14. Click advanced tab and enter $.value as iteration JSON path

  15. Copy the Submit Data and place the new copy under the “Get Repo for Project”

  16. Update the body of Submit Repo Data to be

    { "data":{ "repos":{{{toJSON value}}} } }

Reference API

Quickstart: Configure an app to access a web API - Microsoft identity platform

Graph Explorer | Try Microsoft Graph APIs - Microsoft Graph

https://learn.microsoft.com/en-us/rest/api/azure/devops/git/repositories/list?view=azure-devops-rest-7.1&tabs=HTTP#security

https://learn.microsoft.com/en-us/rest/api/azure/devops/core/projects/list?view=azure-devops-rest-7.1&tabs=HTTP