grayaii
grayaii

Reputation: 2443

How to get a list of users who can log in to jenkins via API

This is similar to how to get all the jenkins users through api, but that provides the list of ALL users, not the users who can actually log in to Jenkins, which is listed under https://[JENKINS]/securityRealm/.

How do you get the list of users that can login to jenkins via an API call? In other words, how do you get the list of users under https://[JENKINS]/securityRealm/ via an API call?

Thanks!

Upvotes: 2

Views: 2002

Answers (1)

zett42
zett42

Reputation: 27796

Class HudsonPrivateSecurityRealm has a method getAllUsers() which is documented as

All users who can login to the system.

Groovy code sample:

Hudson.instance.getSecurityRealm().getAllUsers().each { 
    println it 
}

Upvotes: 3

Related Questions