-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e487040
commit fd98d50
Showing
1 changed file
with
23 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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] | ||
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 | ||
} |