Class: JenkinsApi::Client::User
- Inherits:
-
Object
- Object
- JenkinsApi::Client::User
- Includes:
- UriHelper
- Defined in:
- lib/jenkins_api_client/user.rb
Overview
This class is used to communicate with Jenkins and performing some user level operations - currently limited to fetching user info, but can be extended to support updating user fields
Instance Method Summary (collapse)
-
- (Hash) get(user_id)
Get a single user.
-
- (User) initialize(client)
constructor
Initializes a new User object.
-
- (Hash) list
Get a list of users Response will include same as is available from - (Object) to_s
Returns a string representation of User class.
Methods included from UriHelper
Constructor Details
- (User) initialize(client)
Initializes a new User object.
43 44 45 46 47
# File 'lib/jenkins_api_client/user.rb', line 43 def initialize(client) @client = client @logger = @client.logger @timeout = @client.timeout end
Instance Method Details
- (Hash) get(user_id)
Get a single user
115 116 117
# File 'lib/jenkins_api_client/user.rb', line 115 def get(user_id) response = @client.api_get_request("/user/#{path_encode user_id}") end
- (Hash) list
Get a list of users Response will include same as is available from
Returns:
-
(Hash)
—
of [Hash], keyed by Jenkins user id
-
fullName The jenkins user idoutput+ Console output of the job
-
properties Size of the text. This ca
-
Since:
-
0.14.0
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
# File 'lib/jenkins_api_client/user.rb', line 64 def list @logger.info "Obtaining the list of users from jenkins" # First we need to get the list of users. # This is the same as "System.list_users", but since I didn't want to # depend on that class I reproduced the request here. userlist = @client.api_get_request("/asynchPeople") users = {} userlist['users'].each { |user| # Jenkins seems ok to fetch by full-name, as long as perfect match # since the name *came* from Jenkins this seems reasonably safe user = get(user['user']['fullName']) users[user['id']] = user if user } unless userlist.nil? return users end
- (Object) to_s
Returns a string representation of User class.
51 52 53
# File 'lib/jenkins_api_client/user.rb', line 51 def to_s "#<JenkinsApi::Client::User>" end
-
(Hash)
—