For the complete documentation index, see llms.txt. This page is also available as Markdown.

Harness annotations

You can use annotations to summarize critical information on a pipeline execution.

Pipeline Annotations allow you to publish rich, structured insights directly into the Harness pipeline execution page.

Instead of searching through thousands of lines of logs to find critical information like test summaries, security scan results, or deployment notes, you can use the hcli annotate command to push this data to a dedicated Annotations tab in the Harness UI.

This feature enables you to:

  • Improve debugging: Surface test failures, lint errors, or coverage reports inline.

  • Increase confidence: Review deployment summaries and changelogs at a glance before approval.

  • Reduce toil: Eliminate manual log parsing on an execution's console view for key metrics.

Supported infrastructure

Pipeline Annotations are supported on Kubernetes infrastructure. You can publish annotations from supported shell-based steps, such as Run steps in the Build stage and Shell Script steps in the Deploy stage.

What you will learn from this topic


Before you begin

  • Harness project access: You need View and Execute permissions on Pipelines. An administrator must assign you a role that includes these permissions. For more information, see RBAC in Harness.

  • Kubernetes infrastructure: Pipelines must run on Kubernetes infrastructure. Other infrastructure types are not yet supported.

  • Existing pipeline: You need a pipeline with steps that generate content you want to annotate. For more information, see Add a stage.


Feature availability

Pipeline Annotations are available on supported pipeline infrastructure and execution environments.

This feature is currently behind the feature flags CI_ENABLE_HARNESS_ANNOTATIONS and PIPE_HARNESS_ANNOTATIONS.

If Pipeline Annotations are not available in your account, contact Harness Support to enable these feature flags.


How annotations work

Harness makes the hcli binary available out of the box. There is nothing you need to install or configure. When your script runs hcli annotate, Harness automatically collects the data and publishes it to the Annotations tab.

Perform the following steps to create an annotation:

  1. Generate content: In your shell (for example, a Run step in the Build stage or a Shell step in the Deploy stage), your script generates necessary information (for example, it runs tests and outputs a results.md file).

  2. Run CLI: You call hcli annotate within the same step, specifying a unique context and the content source (a markdown file or inline content).

  3. Publish: Harness securely captures this data and publishes it to the pipeline.

  4. View: The annotation appears in the Annotations tab of the pipeline execution details.


Annotation syntax

Use the following command syntax to publish an annotation from a pipeline step:

Parameters

The hcli annotate command supports the following parameters:

Parameter

Required

Default

Description

--context

Yes

A unique identifier for the annotation within this pipeline execution (for example, test-summary, security-scan).

--summary-file

Conditional

Path to a markdown file containing the annotation content. You must use either this or --summary.

--summary

Conditional

A direct string containing the annotation content. Best for short messages.

--style

No

INFO

Visual style hint for the UI. Options: SUCCESS, INFO, WARNING, FAILURE.

--priority

No

5

Sets priority (1-10). Priority 1 is highest; priority 10 is lowest. Cards are sorted ascending.

--mode

No

replace

Operational mode: replace, append, or delete. For more information, see Annotation modes.


Annotation modes

Use annotation modes to create, update, or remove annotations. The available modes are replace, append, and delete.

Mode

Behavior

replace

Updates only the fields you specify and keeps all other annotation fields unchanged

append

Adds the new --summary or --summary-file content to the end of the existing summary, separated by a newline. If you provide --style or --priority while using append, those values are updated as well.

delete

Removes the entire annotation document associated with the context.


Annotation lifecycle

An annotation is identified by its context within a pipeline execution.

  • The first hcli annotate command with a context creates the annotation.

  • Running the command again with the same context updates the annotation according to the selected mode.

    • Replace updates the existing annotation.

    • Append adds content to the existing summary.

    • Delete removes the annotation associated with the context.

  • A different context creates a separate annotation.

This makes the relationship between context and mode clear for managing annotations throughout pipeline execution.


Example usage

Here is a complete example of a Run step in a Build stage that generates several different markdown files and then uses hcli annotate to publish them as distinct annotations.

Create content: The script first creates three markdown files: build-results.md, coverage.md, and lint-report.md.

Publish annotations:

  • The build-validation annotation is published using the build-results.md file. It is given a warning style and a high priority of 8.

  • The unit-tests annotation is a simple success message passed directly using the --summary flag.

  • The coverage-report and lint-results annotations are created from their respective files, each with its own style and priority.

Append to a context: The final command targets the same build-validation context but uses --mode "append". This adds the content of extra-notes.md to the bottom of the existing build report summary, rather than overwriting it.


View annotations in the UI

During pipeline execution, select the Annotations tab on the execution details page.

The left panel lists all annotation contexts, sorted by priority (highest to lowest).

The right panel displays the rendered markdown summary for the selected annotation.

Annotations are updated as the pipeline executes and hcli annotate commands run.


Annotation content

Annotation summaries use Markdown format for content displayed in the UI.

Supported content includes:

  • Headings

  • Lists

  • Links

  • Code blocks

  • Bold and italic text

  • Standard Markdown images

HTML is not supported and will be stripped for security reasons.

Keep annotation content concise and use links to external reports or artifacts if the content is large.


Key concepts

Context

The --context parameter is the unique key for an annotation within a single pipeline execution.

  • Creating a new annotation: Use a context name that has not been used yet in the execution.

  • Updating an existing annotation: Re-run the hcli annotate command with the same context name. By default, this will replace the existing summary.

Each context can only have one active card in the Annotations tab. Updating with the same context refreshes the same card.

Context uniqueness

A context identifies an annotation within a pipeline execution. Use a stable context name when you want subsequent commands to update the same annotation.

For example, repeatedly using:

updates the test-summary annotation instead of creating a new annotation card.

This reinforces the most important concept behind replace and append.

Limits and guardrails

Pipeline Annotations enforce the following guardrails:

Guardrail

Limit

Behavior on exceeding

Summary size

64KB per annotation

Truncation happens silently in the annotation, with a warning emitted to step logs.

Annotation count

50 annotations per execution

The request is rejected with an error.

Context name length

256 characters

The annotation is skipped, and a warning is logged.


Use pipeline data in annotations

Generate annotation content dynamically from values produced during pipeline execution.

For example, a script can use test results, build versions, deployment information, or pipeline variables to generate a Markdown summary before publishing it.

This approach allows annotations to reflect the results of the current pipeline execution rather than using only static content.


Best practices

Follow these recommendations when publishing annotations:

  • Use meaningful context names (test-summary, coverage, deploy-notes)

  • Prefer concise markdown (less than 10 lines per card)

  • Link to artifacts or dashboards instead of embedding large tables

  • Avoid emojis in context keys (safe in content, not in key)

  • Use append only for incremental updates; prefer replace for clarity


Next steps

Last updated

Was this helpful?