Created
May 9, 2018 14:24
-
-
Save evidex/925fbc47a871141070b81e7dbbcf713f to your computer and use it in GitHub Desktop.
Jenkins Lockable Resources to JSON
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
import org.jenkins.plugins.lockableresources.* | |
def manager = GlobalConfiguration.all().get(org.jenkins.plugins.lockableresources.LockableResourcesManager.class) | |
json = "[" | |
manager.resources.each { lock -> | |
reservedBy = lock.reservedBy ?: "" | |
json += """ | |
{ | |
"name": "${lock.name}", | |
"description": "${lock.description}", | |
"labels": "${lock.labels}", | |
"reservedBy": "${reservedBy}" | |
}, | |
""" | |
} | |
json = json[0..-3] + "]" | |
println json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment