Вот мой текущий код:
Код: Выделить всё
import groovy.text.SimpleTemplateEngine
def call(Map parameters = [:]){
def bindings = (parameters.bindings ?: error('No bindings found')).collectEntries { [it.key, it.value] }
echo "Class of parameters.bindings: ${bindings.getClass()}"
def bindings2 = parameters.bindings
def result = generateHelmFromTemplate(bindings as Map) // Does work perfectly fine!
def result2 = generateHelmFromTemplate(bindings2 as Map) // Does not work! -> java.io.NotSerializableException
echo "Result:\n${result}"
}
def generateHelmFromTemplate(Map bindings2) {
// Load the template from library resources
def templateContent = libraryResource('templates/helm-template.yaml')
def engine = new SimpleTemplateEngine()
return engine.createTemplate(templateContent).make(bindings2).toString()
}
Я изменил код, чтобы клонировать карту привязок с помощью CollectEntries, что предотвращает исключение NotSerializableException:< /p>
Код: Выделить всё
def bindings = (parameters.bindings ?: error('No bindings found')).collectEntries { [it.key, it.value] }
[*]Использовал CollectEntries для клонирования карты параметров.
Подробнее здесь: https://stackoverflow.com/questions/791 ... cause-a-no
Мобильная версия