Hi guys,
My goal here is to add a user to a specific group based on their information from Okta.
My idea to accomplish this is to use the User Created Listener (hoping that this will be fired once a user is created on the instance level and not on the project Level) and use the user's email address to check on Okta the user country and based on the country I would add the user to different groups.
My questions are:
- Will the User created trigger be fired once a user is created on the instance?
- How can I get this user data using Scriptrunner on CLOUD?
- I am assuming that I can do all API calls using Scriptrunner, correct? Can you provide the structure of the API call?
Thanks!
Hi Jao,
I can confirm that ScriptRunner for Jira Cloud can be used to make API calls to either the Jira Cloud Rest APIs located here or external Rest API's.
Also, I can confirm that Atlassian provides a Get User API to get user details and this would be the API to look to return user details from Jira Cloud.
Also you can see details on what the User Created event returns here when it is triggered after a new user is created inside of Jira.
I can confirm that you can see examples of calling the Jira API's here and can see an example of calling an External API here and these examples will show what the structure of rest calls inside of ScriptRunner for Jira Cloud uses.
Finally, I can confirm we have created a Knowledge Base Article located here which you can follow in order to see how to call external rest api's form ScriptRunner for Jira Cloud.
I hope this information helps.
Regards,
Kristian
Hey @Kristian Walker _Adaptavist_
Thanks for all the great information.
There is just one piece of information that I don't have, maybe is due to my lack of understanding of how the triggers work.
Let's say a new user is created (jon.doe@test.com), if I am correct the trigger will fire and the code will run, correct?
Now I need to grab the new user e-mail address to be able to add him to the groups that I want. At this point, the script does not know that his email is jon.doe@test.com.
So the question is, how do I access the event's data to be able to grab the new user email when the trigger is fired?
Thanks again!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Joe,
I can confirm that if you configured the listener to run on the User Created event then it would mean when a user is created that the code in this listener script would be run.
Also, I can confirm that when you create the script listener that if you click the Show me link next to the text which says There are parameters/variables that are automatically available for use within your script: inside the Script Context box that it will show what properties are available in the binding of the event.
For the User Created event you will see there is a user property which is a Map data structure that contains all the details about the user who invoked the event.
If you log out the *user* property in your script then this will show all the details for the user and will show the users email address if the user has chosen not to hide this, as Atlassian now permit users to hide their email addresses so that they are not visible to other users or the API's since the GDPR changes which they introduced last year.
I hope this information helps.
Regards,
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Kristian Walker _Adaptavist_ Thanks very much, as I am new at ScriptRunner I am still getting familiar with it.
Two questions for you :-)
- The email address is always null, is this something related to GDPR?
- Why I can't get the acountID, even though it is present on the user Properties?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jo,
I can confirm you will need to log out what just the user property is in order to see what properties it has that can be logged out.
Also, I can confirm the static type checking warnings are just warnings as described here where the compiler does not understand the code and these mean the script can still be run and these will not stop the script from running.
I would advise you to run the script as the values should still be logged out despite the static type checking warnings.
Finally, yes as mentioned above users can choose to hide the email address and if this is set to hidden on a users profile then this cannot be returned as Atlassian does not expose this via the API since the GDPR changes that they made last year.
I hope this helps,
Regards,
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @Kristian Walker _Adaptavist_
I can confirm that you were very helpful man, really appreciate all the help ;-)
Cheers!
Joao Zampa
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.