diff --git a/script.groovy b/script.groovy index 58434744b8..f438df031b 100644 --- a/script.groovy +++ b/script.groovy @@ -1,7 +1,25 @@ -#!groovy +#!/usr/bin/env groovy -sh 'cat Config.json' -def configs = readJSON(file: 'Config.json') +import groovy.json.JsonSlurper + +// Read the JSON file +def jsonFile = new File('Config.json') +def jsonSlurper = new JsonSlurper() +def configs = jsonSlurper.parse(jsonFile) + +// Calculate the total number of bundles def totalBundles = configs.bundles.size() -println "Total Array Size =" + totalBundles -def productName = new Object[totalBundles] \ No newline at end of file +println "Total Array Size = " + totalBundles + +// Initialize an array for product names +def productName = new Object[totalBundles] + +// Example to fill the array (assuming 'bundles' contains objects with a 'name' property) +configs.bundles.eachWithIndex { bundle, index -> + productName[index] = bundle.product.name +} + +// Print the product names +productName.each { name -> + println "Product Name: " + name +} \ No newline at end of file