|
| 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> |
0 commit comments