Example: Logging Azure DevOps Pipeline Runs
Scenario
A company has a number of development build pipelines that it uses to run code against. This example shows how developers use existing Azure DevOps (ADO) events functionality and Ivanti Neurons for ITSM webhooks to send pipeline data to ITSM. This process transfers valuable information about runs on a particular pipeline into ITSM business objects.
Prerequisites
To recreate this example, you need an Administrator Role for ITSM and ADO pipelines. You also need to set up your Azure DevOps instance to send pipeline results to the webhook that you've created. However, even without an ADO installation, you can understand the principles at work here.
1.In ITSM, create a business object called Pipeline Run. Create the following fields to hold ADO information from a pipeline run:
Field |
Description |
---|---|
Build ID | The ID for the development build that ran. |
Message | Messages about build status appear in this field. |
Build Link | An HTTPS link to open the build in Visual Studio (in this example). |
Git Hash |
The Git hash is a unique content name made up of the following: •The commit message. •The file changes. •The commit author (and committer- they can be different). •The date. •The parent commit hash. |
Description |
User friendly version of the message from the Message field. |
1.Open the Graphical Action Designer.
See: Using the Graphical Action Designer (GAD).
Tip: You can use the Classic Action Designer if you prefer.
2.Create a new block using the Update Variables and Stored Values Action block type. This block updates the stored values and variables used in your Action.
For more help see: Update Stored Values and Variables Quick Action
3. Configure the Update Variables and Stored Values Action block to store the data given to the webhook endpoint in the required variable WebhookBody. Edit the values as follows:
Field |
Value |
---|---|
Variable Type |
Variable |
Name |
WebhookBody |
Data Type |
JSON |
Value |
{} |
4.Create a new block using the Create a New Record block type, name it New action - InsertObject, and attach it to the Update Stored Values and Variables Action block.
5. Edit the New action - InsertObject block.
For EACH field, create an expression using the Simplified Expression Editor to use the variable in the Update Variables and Stored Values Action block to populate that particular field. The expression retrieves a value for the JSON path and uses it to populate the field. For example, use this expression to populate the Build ID field:
$(JSONPathValue(Variable("WebhookBody"), "$.id"))
For help, see: Using the Simplified Expression Editor
6.Save your Action as CreateBuildRun.
1.Create a webhook to trigger the CreateBuildRun Action when data is sent to the appropriate endpoint. In the Settings menu, click on Webhooks Manager in the Build section.
The Webhooks Manager opens.
2.Click Add a Webhook.
3.Enter information into the fields:
Field | Value |
---|---|
Name | Log a Completed Pipeline |
Description | This webhook will create a "Pipeline Run" business object record using the provided data. |
Endpoint Extension |
CompletedPipeline Note: The endpoint extension is case-sensitive. |
Full Endpoint |
https://{tenant url}/api/rest/Webhooks/Execute?extension=CompletedPipeline |
Select Business Object |
Pipeline Runs (PipelineFailure) |
Select Action |
CreateBuildRun (Composite Action) |
4.Click Save.
A confirmation message appears saying Webhook successfully created. Your webhook appears in the list and is enabled by default.
1.To see your webhook in action and test it, find a recently logged build in ADO.
2.In ITSM open the Pipeline Runs business object and select Refresh to check for new records.
3.Open one of the records and check the fields. The record has been created automatically by the CreateBuildRun Action invoked by the Log a Completed Pipeline webhook.