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

Pipeline dynamic execution

Execute pipelines dynamically by providing YAML configuration at runtime without pre-saving pipelines in Harness.

Dynamic pipeline execution allows you run pipelines by providing the pipeline YAML configuration at runtime, without requiring a pre-saved pipeline in Harness.

In this model, Harness acts primarily as the execution engine, while an external system within your ecosystem is responsible for generating and editing the YAML configuration. This approach is particularly useful when pipelines need to be generated dynamically based on user actions.

Dynamic execution also enables integration with existing systems while retaining Harness security and governance controls.


What you will learn from this topic


Before you begin

  • Feature flag required: This feature requires the PIPE_DYNAMIC_PIPELINES_EXECUTION feature flag. Contact Harness Support to enable it.

  • Pipeline permissions: Edit and Execute permissions on pipelines. For more information, refer to Manage roles.

  • Existing pipeline: The pipeline must already exist in Harness UI. The pipeline-level dynamic execution setting is only visible after the account-level setting is enabled.

  • API access: Dynamic execution is only supported via the API endpoint: https://app.harness.io/gateway/pipeline/api/v1/orgs/{org}/projects/{project}/pipelines/{pipeline}/execute/dynamic

Feature flag availability

If you do not see the dynamic execution options in your account, the feature flag may not be enabled. Contact Harness Support at support@harness.io to enable the PIPE_DYNAMIC_PIPELINES_EXECUTION feature flag.


Enable dynamic execution

Before you can execute pipelines dynamically, you need to enable two settings at both the account and pipeline levels.

Account level setting

  1. Navigate to Account Setting, then select Default Settings.

  2. Select Pipeline.

  3. Enable Allow Dynamic Execution for Pipelines.

You can disable dynamic execution for the account at any time by turning off this setting.

Pipeline level setting

After enabling the account setting, you must enable the pipeline-level setting in your pipeline.

  1. Navigate to Advanced Options.

  2. Select Dynamic Execution Settings (optional).

  3. Enable Allow Dynamic Execution for Pipeline.


Supported features

Dynamic pipeline execution supports the following features:

  • Template resolution at runtime: Resolve templates dynamically when the pipeline executes.

  • Expression resolution: Use Harness expressions in your dynamic YAML.

  • Services and environments: Reference existing services and environments in your dynamic pipelines.

  • Secrets and connectors: Access secrets and connectors configured in Harness.

  • OPA policy enforcement: Apply Open Policy Agent (OPA) policies to dynamic pipelines.


Use the dynamic execution API

The Dynamic Execution API in Harness allows you to execute a pipeline dynamically by passing YAML configurations directly in the request body.

To execute a pipeline dynamically, you must provide a valid YAML configuration through the Dynamic Execution API.

API request format

Replace the following placeholders:

  • PROJECT_ID: Your Harness project identifier

  • PIPELINE_ID: Your pipeline identifier

  • ACCOUNT_ID: Your Harness account identifier

  • HARNESS_API_KEY: Your Harness API key

Example API request

API response

Upon successful execution, the API returns the following response:

Monitor pipeline execution

Once the API is triggered, you can monitor the pipeline execution in the Harness UI.

In the trigger summary you will see a message indicating This was executed dynamically. This confirms that the pipeline was triggered using the Dynamic Execution API.

Example pipeline with dynamic stage

This example demonstrates how to transform and execute dynamically generated YAML within a running pipeline.

YAML example: Pipeline with dynamic stage

In this example:

  • The generate_yaml stage uses a plugin to generate Harness pipeline YAML dynamically.

  • The plugin outputs the generated YAML to the variable PLUGIN_HARNESS_YAML.

  • The execute_generated_yaml dynamic stage consumes this output variable via the source field.

  • When the pipeline executes, the dynamic stage appends and runs the newly generated stages or steps.


Generate and execute dynamic stages

You can generate pipeline stages or steps at runtime and append them to the executing pipeline using a Dynamic stage type.

To add a Dynamic stage:

  1. Add a Dynamic stage to your pipeline.

  2. In Source Location, specify the location of the dynamically generated YAML.

  3. Configure the preceding stage to generate the pipeline YAML during execution.

  4. Store the generated YAML in a pipeline variable.

  5. Configure the Dynamic stage to consume the variable containing the generated YAML.

  6. Run the pipeline. The Dynamic stage uses the generated YAML to add and execute the new stages or steps.

The stage before the dynamic stage generates pipeline YAML and outputs it to a variable that the dynamic stage consumes. For a complete working example, go to Example pipeline with dynamic stage.


Limitations

Dynamic pipeline execution does not support the following features:

  • Input sets: Cannot use input sets with dynamic execution.

  • Selective stage execution: Cannot selectively execute specific stages.

  • Retry or re-run capability: Cannot retry or re-run dynamically executed pipelines.

  • Automatic triggers: Cannot configure automatic triggers for dynamic pipelines.

  • Post production rollback: Post production rollback is not available.

  • Runtime inputs: Cannot use runtime inputs in dynamic execution.


Next steps

  • Add a stage: Learn how to create and configure pipeline stages.

  • RBAC in Harness: Understand how to manage permissions for pipelines.

  • Templates: Use templates for reusable pipeline configurations.

Last updated

Was this helpful?