IBM Cloud Docs
Adding DevOps Insights to your toolchain

Adding DevOps Insights to your toolchain

Use IBM Cloud® DevOps Insights to help improve build quality for your projects. DevOps Insights is a tool that provides data for team insights and deployment risk. Get insights about your application by uploading unit tests, code coverage, functional verification tests, and static security scans for each application to DevOps Insights.

Before you begin

To use DevOps Insights, you must have a toolchain. A toolchain is a group of tools that are attached to one of your applications. Think of the tools as enhancements to the app and the toolchain as a utility belt. DevOps Insights works with the other tools in the toolchain, like GitHub and Delivery Pipeline, to aggregate data for your application.

For more information about toolchains, see Creating a toolchain from an app.

Integrating DevOps Insights

Integrating DevOps Insights by using the console

You can add DevOps Insights to any toolchain by selecting it from the tool integration catalog.

  1. From the IBM Cloud console, click the menu icon hamburger icon > DevOps.
  2. Select your toolchain.
  3. Click Add tool.
  4. Select the DevOps Insights tile.
  5. Click Create Integration.
  6. On the Toolchain's Overview page, on the IBM Cloud tools card, click DevOps Insights to view your DevOps Insights dashboard.

Integrating DevOps Insights with the API

  1. Obtain an IAM bearer token. Alternatively, if you are using an SDK, obtain an IAM API key and set the client options by using environment variables.

    export CD_TOOLCHAIN_AUTH_TYPE=iam && \
    export CD_TOOLCHAIN_APIKEY={iam_api_key} && \
    export CD_TOOLCHAIN_URL={base_url}
    
  2. Determine the region and ID of the toolchain that you want to add the DevOps Insights tool integration to.

  3. Add the DevOps Insights tool integration to the toolchain.

    curl -X POST \
      {base_url}/toolchains/{toolchain_id}/tools \
      -H 'Authorization: Bearer {token}' \
      -H 'Accept: application/json` \
      -H 'Content-Type: application/json' \
        -d '{
        "tool_type_id": "draservicebroker",
        "name": "{tool_integration_name}"
      }'
    
    const CdToolchainV2 = require('@ibm-cloud/continuous-delivery/cd-toolchain/v2');
    ...
    (async () => { 
       const toolchainService = CdToolchainV2.newInstance();
       const draPrototypeModel = {
          toolchainId: {toolchain_id},
          toolTypeId: 'draservicebroker',
          name: {tool_integration_name}
       };
       const draTool = await toolchainService.createTool(draPrototypeModel);
    })();
    
    import (
        "github.com/IBM/continuous-delivery-go-sdk/cdtoolchainv2"
    )
    ...
    toolchainClientOptions := &cdtoolchainv2.CdToolchainV2Options{}
    toolchainClient, err := cdtoolchainv2.NewCdToolchainV2UsingExternalConfig(toolchainClientOptions)
    createDraToolOptions := toolchainClient.NewCreateToolOptions({toolchain_id}, "draservicebroker")
    createDraToolOptions.SetName({tool_integration_name})
    draTool, response, err := toolchainClient.CreateTool(createDraToolOptions)
    
    from ibm_continuous_delivery.cd_toolchain_v2 import CdToolchainV2
    ...
    toolchain_service = CdToolchainV2.new_instance()
    dra_tool = toolchain_service.create_tool(
       name = {tool_integration_name},
       toolchain_id = {toolchain_id},
       tool_type_id = "draservicebroker"
    )
    
    import com.ibm.cloud.continuous_delivery.cd_toolchain.v2.CdToolchain;
    import com.ibm.cloud.continuous_delivery.cd_toolchain.v2.model.*;
    ...
    CdToolchain toolchainService = CdToolchain.newInstance();
    CreateToolOptions createDraToolOptions = new CreateToolOptions.Builder()
       .name({tool_integration_name})
       .toolchainId({toolchain_id})
       .toolTypeId("draservicebroker")
       .build();
    Response<ToolchainToolPost> response = toolchainService.createTool(createDraToolOptions).execute();
    ToolchainToolPost draTool = response.getResult();
    

The following table lists and describes each of the variables that are used in the previous steps.

Table 1. Variables for adding the DevOps Insights tool integration with the API
Variable Description
{base_url} The Toolchain API endpoint URL, for example https://api.us-south.devops.cloud.ibm.com/toolchain/v2. For more information about this endpoint URL, including a list of values, see Endpoint URL.
{iam_api_key} Your IAM API key.
{tool_integration_name} A name for your tool integration.
{toolchain_id} The ID of the toolchain to which to add the tool integration.
{token} A valid IAM bearer token.

For more information about the DevOps Insights tool integration, see Adding DevOps Insights.

Integrating DevOps Insights with Terraform

  1. To install the Terraform CLI and configure the IBM Cloud provider plug-in for Terraform, follow the tutorial for Getting started with Terraform on IBM Cloud.

  2. Locate the Terraform file (for example, main.tf) that contains the resource block for the toolchain to which you want to add the DevOps Insights tool integration. In this file, add the configuration to create the tool integration.

    The following example creates the toolchain if it does not exist, then adds the DevOps Insights tool integration by using the ibm_cd_toolchain_tool_devopsinsights resource.

    data "ibm_resource_group" "group" {
      name = "default"
    }
    
    resource "ibm_cd_toolchain" "cd_toolchain" {
      name              = "my toolchain"
      resource_group_id = data.ibm_resource_group.group.id
    }
    
    resource "ibm_cd_toolchain_tool_devopsinsights" "cd_toolchain_tool_insights" {
      toolchain_id = ibm_cd_toolchain.cd_toolchain.id
    }
    

    For more information about ibm_cd_toolchain_tool_devopsinsights, see the argument reference details in the Terraform Registry Documentation.

  3. Initialize the Terraform CLI.

    terraform init
    
  4. Create a Terraform execution plan. This plan summarizes all of the actions that must run to add the DevOps Insights tool integration to the toolchain.

    terraform plan
    
  5. Apply the Terraform execution plan. Terraform takes all of the required actions to add the DevOps Insights tool integration to the toolchain.

    terraform apply
    

For more information about using Terraform with Continuous Delivery, see Setting up Terraform for Continuous Delivery.

Next steps

After you add DevOps Insights, you can publish quality data from other sources. These sources include IBM® Continuous Delivery Pipeline for IBM Cloud® in the toolchain, Jenkins, Travis CI, or other pipelines. To learn more, see aggregating data from multiple sources into a single toolchain.