Skip to main content

Identifying CI Jobs on Specific Runners Using CircleCI API

Overview

In situations where you need to identify which CI jobs ran on specific runners, CircleCI provides tools to help you gather this information. While the API does not directly provide runner hostnames, it can return executor details, including the runner resource class. This article outlines how to use the CircleCI API and CLI to retrieve relevant job and runner information.

Prerequisites

  • Access to CircleCI API v2 documentation.

  • CircleCI CLI installed and configured.

Instructions

Retrieve Executor Details Using CircleCI API

  1. Use the getJobDetails API endpoint to obtain executor details for a specific job. This will include the runner resource class.

    • API Endpoint: Get Job Details

    • Example of relevant snippet from the response: json "executor": { "resource_class": "namespace/resource-class-name", "type": "runner" }

List Runner Instances Using CircleCI CLI

  1. Once you have the runner resource class, use the CircleCI CLI to list instances of the runner.

    • Command: bash circleci runner instance list <namespace/resource-class>

  2. This command will provide a list of runner instances associated with the specified resource class.

Solution

While the API does not provide direct access to runner hostnames, combining the API and CLI allows you to gather necessary details about the runners used in your CI jobs. If historical data is required, consider integrating job history logging into a system like Splunk for future reference.

Additional Resources

Did this answer your question?