KBEC-00483 - Property Expansion Exceeds Maximum Allowed Character Limit

Article ID:360056467032
1 minute readKnowledge base

Summary

You want to use a property whose value is extremely large in a Groovy job. When the property is expanded, you see the following error:

String too long. The given string is 85408 Unicode code units long, but only a maximum of 65535 is allowed.

Problem

This issue can occur if you expand properties using $[/path/to/property]. The way to understand this is as follows:

Prior to the script being executed by the Groovy interpreter, it is parsed by the CD interpreter and the $[myvar] notation is written as text into the Groovy script. Then the Groovy script simply has a string constant. There is a Groovy limitation where string constants cannot exceed 65535 characters.

Solution

Instead of expanding properties like:

$[/path/to/property]

You should instead use:

ef.getProperty(propertyName: "/path/to/property").property.value

This getProperty mechanism for retrieving the value is functionally equal to the $[/path/to/property] method, but the method is a Groovy method being executed in the script by the Groovy interpreter and so it comes in escaped for Groovy.

Environment

  • All

This article is part of our Knowledge Base and is provided for guidance-based purposes only. The solutions or workarounds described here are not officially supported by CloudBees and may not be applicable in all environments. Use at your own discretion, and test changes in a safe environment before applying them to production systems.