Skip to content

Instantly share code, notes, and snippets.

@evidex
Created May 9, 2018 14:24
Show Gist options
  • Save evidex/925fbc47a871141070b81e7dbbcf713f to your computer and use it in GitHub Desktop.
Save evidex/925fbc47a871141070b81e7dbbcf713f to your computer and use it in GitHub Desktop.
Jenkins Lockable Resources to JSON
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