Wednesday 31 March 2021

Expanding a User model property in Jenkins REST API

I am trying to extract last login details of a user by using Jenkins REST APIs, upon querying for the URL https://jenkinsurl/user/someusername/api/json I receive a response similar to the one shown below.

{
      "_class" : "hudson.model.User",
      "absoluteUrl" : "https://jenkinsurl/user/someusername",
      "description" : null,
      "fullName" : "someusername",
      "id" : "someusernameid",
      "property" : [
        {
          "_class" : "someProperty1"
        },
        {
          "_class" : "someProperty2"
        },
        
        {
          "_class" : "org.jenkinsci.plugins.saml.user.LoginDetailsProperty"
        },
      ]
    }

Now the details I am looking for are under LoginDetailsProperty which can be found in the source here. I have seen the details been used in the Jenkins UI when I open user/someusername/configure to modify user details or create access token. How can I expand the LoginDetailsProperty and extract the lastLoginTimestamp value for a particular user using REST APIs?



from Expanding a User model property in Jenkins REST API

No comments:

Post a Comment