• Icon: Improvement Improvement
    • Resolution: Not A Defect
    • Icon: Major Major
    • core

      I've searched for a means to obtain the id of the currently logged in User, but incredibly this info is not easily queried.

      Existing solutions using User.current(), or Cause.UserIdCause() for triggered builds, are not reliable. User.current() results in SYSTEM whenever I try to use it. Cause.UserIdCause is only useful to me if I'm able to access it, and when I'm working with slaves it doesn't seem to be set for the master build triggered by a user.

      Yet, while I'm hunting around, I can see that the user id is always displaying in the top right corner of the UI, taunting me since it is the information I want, but seemingly not available.

      Surely this shouldn't be so hard or obtuse. If I just had the id, I could look up the User with a User.get(id) and be on my merry way.

      Thanks.

          [JENKINS-14605] Simple means to obtain logged in user's id

          Was too long ago, don't even remember the fact that I asked this question, sorry

          Stanislav Bashkyrtsev added a comment - Was too long ago, don't even remember the fact that I asked this question, sorry

          The problem persists. The two commands below return SYSTEM when they are run inside a pipeline script.

           

          User.current()Jenkins.getAuthentication().getName()

           

          Currently there is no way get the logged in user from a pipeline.

          Paulo Eduardo Neves added a comment - The problem persists. The two commands below return SYSTEM when they are run inside a pipeline script.   User.current() Jenkins.getAuthentication().getName()   Currently there is no way get the logged in user from a pipeline.

          Jesse Glick added a comment -

          Remember that these methods are generally only meaningful within the dynamic scope of an HTTP request or CLI command. Use the dev mailing list or IRC if you still have issues.

          Jesse Glick added a comment - Remember that these methods are generally only meaningful within the dynamic scope of an HTTP request or CLI command. Use the dev mailing list or IRC if you still have issues.

          This is still an issue and I don't quite understand why this JIRA ticket has been closed.

          Could you please clarify how to retrieve the currently logged-in user from a shared library? Is this currently possible or not? Everything I tried so far returns SYSTEM as mentioned above. The behavior is different from the use of those API calls from the Groovy console (which works as expected).

          Benjamin Muschko added a comment - This is still an issue and I don't quite understand why this JIRA ticket has been closed. Could you please clarify how to retrieve the currently logged-in user from a shared library? Is this currently possible or not? Everything I tried so far returns SYSTEM as mentioned above. The behavior is different from the use of those API calls from the Groovy console (which works as expected).

          Jesse Glick added a comment -

          Reread the prior comments. There is no such thing as “the currently logged-in user from a shared library”.

          Jesse Glick added a comment - Reread the prior comments. There is no such thing as “the currently logged-in user from a shared library”.

          jglick Thanks for confirming. Just for my and other people's understanding, could you also provide some technical details on why this functionality is not available?

          Benjamin Muschko added a comment - jglick Thanks for confirming. Just for my and other people's understanding, could you also provide some technical details on why this functionality is not available?

          Jesse Glick added a comment -

          A build is not generally run with any association with a user whatsoever. The question just does not make sense. If a build happened to be triggered manually by a user (which is not the normal case), that information is already available via UserIdCause.

          Jesse Glick added a comment - A build is not generally run with any association with a user whatsoever. The question just does not make sense. If a build happened to be triggered manually by a user (which is not the normal case), that information is already available via UserIdCause .

          J added a comment -

          jglick What if we are using a kind of approval? In this case, original user (developer) could be different to approval user (tester/leader).

          In my case I created a job which is able to deploy on testing and production environments. I need to allow production deployments just to specific users using pipeline.

          Thanks

          J added a comment - jglick What if we are using a kind of approval? In this case, original user (developer) could be different to approval user (tester/leader). In my case I created a job which is able to deploy on testing and production environments. I need to allow production deployments just to specific users using pipeline. Thanks

          Jesse Glick added a comment -

          Questions about Jenkins usage are best sent to the users’ list or other forums rather than the issue tracker.

          Jesse Glick added a comment - Questions about Jenkins usage are best sent to the users’ list or other forums rather than the issue tracker.

          Vijay Nalubotula added a comment - - edited

          Have been digging the whole internet for a simple call which gives me logged in jenkins user. wow. this is crazy. No solutions. Instead looks like its pointed here, that our requirements cud be wrong.

           

          I am working with dynamic job parameters , where i require logged in user , based on which my parameter values will change. I have not even entered into the job , to use hudson.model.Cause.UserIdCause

          Vijay Nalubotula added a comment - - edited Have been digging the whole internet for a simple call which gives me logged in jenkins user. wow. this is crazy. No solutions. Instead looks like its pointed here, that our requirements cud be wrong.   I am working with dynamic job parameters , where i require logged in user , based on which my parameter values will change. I have not even entered into the job , to use hudson.model.Cause.UserIdCause

            Unassigned Unassigned
            dankirkd Daniel Kirkdorffer
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: