Skip to content

Commit 31ebf0c

Browse files
authored
Merge pull request #9923 from harness/dewan-ci15398
Add details from CI-15398
2 parents b403878 + dfb2efe commit 31ebf0c

File tree

4 files changed

+78
-2
lines changed

4 files changed

+78
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
title: Enhanced Output Variable Handling in CI Steps
3+
description: Learn about the new enhancements in CI steps, including multiline output variable support, improved output handling, JSON preservation, and updated best practices.
4+
sidebar_position: 50
5+
---
6+
<details>
7+
<summary>Early access feature: Multi-line Output Variables</summary>
8+
- **Multiline Output Variables**: CI steps support multiline output variables, including special characters such as `\n`, `\t`, `\r`, `\b`, maintaining shell-like behavior.
9+
- **Complete Output Support**: Output variables support both output secrets and output strings.
10+
- **JSON Preservation**: JSON data can be passed as-is without automatic minification.
11+
- **Increased Output Variable Capacity**: The maximum output variable size is approximately **131,072 characters**, up from 65,536.
12+
13+
#### Technical Limitations
14+
- The **maximum size** of output variables is constrained by the operating system's `ARG_MAX` parameter, which limits command line arguments and environment variables.
15+
- Exceeding this limit will result in the error:
16+
```shell
17+
fork/exec /bin/sh: argument list too long
18+
```
19+
- This limitation is imposed by the operating system, not by the implementation of this feature.
20+
21+
#### Behavior Changes: Current vs. New
22+
The following table outlines changes in how special characters are handled in output variables:
23+
24+
| Command | Current Behavior | New Behavior |
25+
|---------------------|-----------------|-------------|
26+
| `export out="\b"` | `"\b"` | Backspace |
27+
| `export out="\f"` | `"\f"` | Form feed |
28+
| `export out="\n"` | `"\n"` | Newline character |
29+
| `export out="\r"` | `"\r"` | Carriage return |
30+
| `export out="\t"` | `"\t"` | Tab character |
31+
| `export out="\v"` | `"\v"` | Vertical tab |
32+
33+
#### Best Practices
34+
35+
**Python Shell**
36+
For multiline strings in Python, use triple quotes (`"""` or `'''`) to maintain formatting properly.
37+
38+
**Step 1:** Export an output variable:
39+
```python
40+
out = """line1,
41+
line2,
42+
line3"""
43+
os.environ["out"] = out
44+
```
45+
46+
**Step 2:** Read the output variable:
47+
```python
48+
str_value = """<+execution.steps.Step_name.output.outputVariables.out>"""
49+
```
50+
51+
**PowerShell**
52+
For PowerShell, use the `@"..."@` syntax to handle multiline strings effectively.
53+
54+
**Step 1:** Export an output variable:
55+
```powershell
56+
$out=@"
57+
line1,
58+
line2,
59+
line3
60+
"@
61+
$env:out = $out
62+
```
63+
64+
**Step 2:** Read the output variable:
65+
```powershell
66+
$str_value = @"
67+
<+execution.steps.Step_name.output.outputVariables.out>
68+
"@
69+
```
70+
71+
These best practices ensure proper handling of multiline strings across different environments while maintaining consistency in CI workflows.
72+
</details>

Diff for: docs/continuous-integration/shared/output-var.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ In the following YAML example, step `alpha` exports an output variable called `m
3333
3434
* **Secrets in output variables exposed in logs:** If an output variable value contains a secret, be aware that the secret will be visible in the [build details](/docs/continuous-integration/use-ci/viewing-builds.md). Such secrets are visible on the **Output** tab of the step where the output variable originates and in the build logs for any later steps that reference that variable. For information about best practices for using secrets in pipelines, go to the [Secrets documentation](/docs/category/secrets).
3535
* **64KB length limit:** If an output variable's length is greater than 64KB, steps can fail or truncate the output. If you need to export large amounts of data, consider [uploading artifacts](/docs/continuous-integration/use-ci/build-and-upload-artifacts/build-and-upload-an-artifact#upload-artifacts) or [exporting artifacts by email](/docs/continuous-integration/use-ci/build-and-upload-artifacts/drone-email-plugin.md).
36-
* **Single line limit:** Output variables don't support multi-line output. Content after the first line is truncated. If you need to export multi-line data, consider [uploading artifacts](/docs/continuous-integration/use-ci/build-and-upload-artifacts/build-and-upload-an-artifact#upload-artifacts) or [exporting artifacts by email](/docs/continuous-integration/use-ci/build-and-upload-artifacts/drone-email-plugin.md).
36+
* **Single line limit:** By default, output variables are limited to a single line. To enable multi-line output variables, use the feature flag `CI_NEW_VERSION_GODOTENV`. To export multi-line data, you can also consider [uploading artifacts](/docs/continuous-integration/use-ci/build-and-upload-artifacts/build-and-upload-an-artifact#upload-artifacts) or [exporting artifacts by email](/docs/continuous-integration/use-ci/build-and-upload-artifacts/drone-email-plugin.md).
3737
* **Exit Codes:** In the event that an exit code is defined and set in the script, the output variables will not be available as an output from the step because it is a "forced" exit. The output from the step will be empty which can be desired depending on the situation.
3838
This includes `exit 0` definitions. Therefore, customers should not define an **exit 0 situation**, as "completing the script" to the end is what is expected as a "healthy" completion of the script.
3939
:::

Diff for: docs/continuous-integration/use-ci/run-step-settings.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ redirect_from:
1414

1515
import Tabs from '@theme/Tabs';
1616
import TabItem from '@theme/TabItem';
17+
import EnhancedOutVar from '/docs/continuous-integration/shared/enhanced-output-variables.md';
1718
import OutVar from '/docs/continuous-integration/shared/output-var.md';
1819

1920
You can use a **Run** step to run commands or scripts in a CI pipeline. Here are some examples of different ways you can use **Run** steps.
@@ -455,7 +456,7 @@ Variable values can be [fixed values, runtime inputs, or expressions](/docs/plat
455456
### Output Variables
456457

457458
<OutVar />
458-
459+
<EnhancedOutVar/>
459460
<!--<details>
460461
<summary>Export output variables to stage or pipeline variables</summary>
461462

Diff for: docs/continuous-integration/use-ci/run-tests/tests-v2.md

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ sidebar_position: 3
55
---
66

77
import OutVar from '/docs/continuous-integration/shared/output-var.md';
8+
import EnhancedOutVar from '/docs/continuous-integration/shared/enhanced-output-variables.md';
89
import Tabs from '@theme/Tabs';
910
import TabItem from '@theme/TabItem';
1011

@@ -167,6 +168,8 @@ When using **.Net**, make sure to enable log reporting when running the tests, e
167168

168169
<OutVar />
169170

171+
<EnhancedOutVar/>
172+
170173
### Environment Variables
171174

172175
You can inject environment variables into the step container and use them in the step's commands. You must input a **Name** and **Value** for each variable.

0 commit comments

Comments
 (0)