I have the below template yaml in my github
kind: Endpoints
apiVersion: v1
metadata:
name: SERVICENAME
namespace: NAMESPACE
subsets:
- addresses:
- ip: SERVICEADDRESS
ports:
- port: SERVICEPORT
I am trying to parse this yaml file in Jenkins pipeline and append values to placeholders like below.
kind: Endpoints
apiVersion: v1
metadata:
name: test
namespace: testnamespace
subsets:
- addresses:
- ip: 10.22.33.22
- ip: 10.22.11.33
ports:
- port: 1042
I am able to read the yaml as an object using below code
def extEpData = readYaml (file: 'external-ep.yaml')
Not able to append multiple ip addresses to the list
extEpData.metadata.name = serviceName
extEpData.metadata.namespace = namespace
extEpData.subsets[0].ports[0].port = servicePort as int
for (int i=0; i<=addressList.size(); i++) {
echo addressList[i]
extEpData.subsets[0].addresses[0].ip = addressList[i]
}
writeYaml file: 'external-ep.yaml', data: extEpData, overwrite: true
addressList array holds the ip list. Above code is not appending multiple ip addresses. Its only working for one ip address. What am I doing wrong?