Skip to content

Instantly share code, notes, and snippets.

@alipandidan
Created November 9, 2020 05:24
Show Gist options
  • Save alipandidan/d6390841b4ecb46a7a6fc61fb2fe5197 to your computer and use it in GitHub Desktop.
Save alipandidan/d6390841b4ecb46a7a6fc61fb2fe5197 to your computer and use it in GitHub Desktop.
Jenkins list groups on all items
// It's 6:00 and I haven't slep, I'll clean it later
// import nectar.plugins.rbac.groups.*
// import com.cloudbees.hudson.plugins.folder.*
// import com.cloudbees.jenkins.plugins.foldersplus.*
// import com.cloudbees.hudson.plugins.folder.properties.FolderProxyGroupContainer
// import nectar.plugins.rbac.groups.JobProxyGroupContainer
// for (item in Jenkins.instance.getAllItems()) {
// if (item instanceof com.cloudbees.hudson.plugins.folder.Folder) {
// AbstractFolder < ? > folderAbs1 = AbstractFolder.class.cast(item)
// FolderProxyGroupContainer propertyFPG = folderAbs1.getProperties().get(FolderProxyGroupContainer.class)
// if (propertyFPG != null) {
// propertyFPG.getGroups().findAll{it != null}.each {
// println item.fullName + " : " + it.name
// }
// }
// } else {
// // def locationJob = Jenkins.instance.getAllItems().find{it.fullName.equals(item.fullName)}
// // GroupContainer container = GroupContainerLocator.locate(locationJob)
// def groupContainers = item.getProperties().get(com.cloudbees.hudson.plugins.modeling.integrations.rbac.ModelProxyGroupContainer.class)
// println groupContainers.groups
// }
// }
// if (propertyFPG != null) {
// println propertyFPG.getGroups().findAll{it != null}.collect { it.name }.join(',')
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment