Workspace Expressions
Harness workspace expressions empower you to dynamically reference workspace-level parameters within your pipelines, enhancing flexibility and customization. By leveraging JEXL (Java Expression Language), you can seamlessly access key workspace attributes.
Key Benefits
- Dynamic Retrieval: Access workspace-specific identifiers and paths effortlessly.
- Environment Integration: Utilize environment and secret variables within the workspace context.
- Versioning and Provisioning: Integrate versioning and provisioner details directly into your pipeline logic.
- Cost Management: Extract outputs and control cost estimation features.
- Git Management: Seamlessly manage Git-related parameters like repository name, branch, commit SHA, and tags.
These expressions are invaluable when adapting pipelines to different environments or configurations.
Go to the Migrate Expressions tab in the How to Use Workspace Expressions section to update old expressions to the latest format.
Available Workspace Expressions
Supported workspace expressions are written in the syntax <+workspace.ATTRIBUTE>
, where ATTRIBUTE can be a single or multi-level identifier, such as:
<+workspace.identifier>
<+workspace.type>
(e.g., opentofu)<+workspace.envVars.SOME_ENV_VAR>
See full list of supported workspace expressions
How to Use Workspace Expressions
Here's an example of applying workspace expressions in your pipelines to output the workspace identifier and secret variable value.
Avoid naming your run step workspace
as it is a reserved keyword.
- Interactive Guide
- Migrate Expressions
If you're using an older expression format, update it to the new format as follows:
For example, update secret variables from:
// OLD
<+pipeline.stages.stage_name.spec.execution.steps.step_name.spec.secretVariables.secret_variable_name>
// NEW
<+workspace.envVars.SECRET_ENV_VAR>
The following guide demonstrates updating your workspace's secret environment variable reference:
See the reference of old and new expression formats:
See old and new expressions
By understanding and utilizing workspace expressions in Harness IaCM, you can significantly enhance the efficiency and adaptability of your infrastructure management processes.