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
How to enable dynamic execution at account and pipeline levels.
How to generate and execute dynamic stages within a running pipeline.
Before you begin
Feature flag required: This feature requires the
PIPE_DYNAMIC_PIPELINES_EXECUTIONfeature 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
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
Navigate to Account Setting, then select Default Settings.
Select Pipeline.
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.
Navigate to Advanced Options.
Select Dynamic Execution Settings (optional).
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 identifierPIPELINE_ID: Your pipeline identifierACCOUNT_ID: Your Harness account identifierHARNESS_API_KEY: Your Harness API key
Troubleshooting API authentication errors
If the API returns an authentication error or permission denied, verify you have both Edit and Execute permissions on the pipeline. For more information, refer to Manage roles.
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.
In this example:
The
generate_yamlstage uses a plugin to generate Harness pipeline YAML dynamically.The plugin outputs the generated YAML to the variable
PLUGIN_HARNESS_YAML.The
execute_generated_yamldynamic stage consumes this output variable via thesourcefield.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:
Add a Dynamic stage to your pipeline.
In Source Location, specify the location of the dynamically generated YAML.
Configure the preceding stage to generate the pipeline YAML during execution.
Store the generated YAML in a pipeline variable.
Configure the Dynamic stage to consume the variable containing the generated YAML.
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?