Ubuntu – Jenkins list user ids using script console

Jenkinsscriptsusers

I want to list all users in jenkins, via the console script that jenkins has.

So far I managed to list all the users using this:

import hudson.model.User   
User.getAll().each { user ->   
   println user}

but they are listed by the first and last name, which I don't need…

I would like to list them by their user IDs, can you give me a hand?

I looked through the documentation but I fail to understand how to use it the right way. I'm not so experimented with groovy scripting..

Any ideas? Thank you!

Best Answer

According to the hudson.modle.User documentation, you can use the getId() method to get the user's id.

Probably like that:

import hudson.model.User
User.getAll().each { user ->
println user.getId()}