I am using the Pipeline Utility Steps to read and updated the yaml files in my repo. However there is one key (chart-name) which has "-" (not "_", I know this is not preferred but its there). Now the problem i am facing is that "-" is considered as "binary expression" and its giving the error. '''
script {
def filename = "values.yaml"
def data = readYaml file: filename
data.chart-name.image.image = "imange name"
sh "rm $filename"
writeYaml file: filename, data: data
}
''' Error: (data.chart - name.image.ports.containerPort) is a binary expression, but it should be a variable expression at line: 96 column: 51. File: WorkflowScript @ line 96, column 51. name.image.ports.containerPort = "${param
You can use the quotation syntax for accessing Map-like objects in Groovy, e.g.:
data.'chart-name'.image.image = "image name"
Of course, you might want to make sure nothing on that chain returns a null value...