Last active
June 19, 2017 17:37
-
-
Save brianoflan/82db28f9361cce796dba7458ed6d8c60 to your computer and use it in GitHub Desktop.
Get a map's keys in a Jenkinsfile's Groovy sandbox
This file contains hidden or 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
@NonCPS | |
def getKeys(map) { | |
def keylist = [] | |
for (def entry in map) { | |
// For converting map into list: | |
// // keylist.add(new java.util.AbstractMap.SimpleImmutableEntry(entry.key, entry.value)) | |
keylist.add(entry.key) | |
} | |
keylist | |
} | |
def test_hash() { | |
util1([name: 'abc', jName: 'jabc', 'gName': 'gabc']) | |
} | |
def util1(the_datums) { | |
def data_keys = getKeys(the_datums) | |
// // or just | |
// def data_keys = the_datums.keySet() as String[] | |
for (int i = 0; i < data_keys.size(); i++) { | |
echo "i ${i}" | |
echo " key ${data_keys[i]}" | |
echo " the_datums[data_keys[i]] ${the_datums[data_keys[i]]}." | |
} | |
} | |
stage('overall') { node() { timeout(time: 11, unit: 'MINUTES') { | |
test_hash() | |
} } } | |
// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment