Hi I use scriptrunner in jira. I created listener with some functionalities, when issue created. If I create issue by jira gui it works fine.
I have problem, when I create issue by api etc. (by python), my listener works again, but I don't want it. What solution will you suggest?
Try to differentiate your issues created by API and through GUI by some field value and use that as a condition in your listener to either skip or process .
Example:
If you are using a BOT account for API , and create the issue with the BOT user as reporter , you can use that as a condition .
OR
In summary , have a prefix like [ Automation ] < summary goes here > for API created issues and use it as a filter .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Or... rather than having two pieces of information in the Summary field (source and summary), consider using a different field to indicate the source, such as Labels, Components, or a custom field. That will make searches, analysis, and updates easier in the future.
Best regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the reply.
We have SSO configured were in, when an user logs in our app, he gets log-in in jira.
At that point of time, our API user and jira user are same.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
How can I differentiate whether issueEvent raised is because of some transition made using UI or it is made by API call.
I need to make 3rd party call only when transition get updated by UI not by API
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Your api call must have a user-id . You can capture logged-in user name and compare if it's the api-user or an actual UI user .
import com.atlassian.jira.component.ComponentAccessor
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().name
def apiUser = "bot"
if ( currentUser == apiUser ){
// exit
}
else {
// execute 3rd party call
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
if jira is logged in and API action is performed.
Will
ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().name
give actionable user?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Your API user authenticates first and perform any action thereafter . Any action performed by that user can be captured as I mentioned above .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
String loggedInUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().getName();
It always return the logged in user and not the API user who performed action.
There are possibility, that jira is logged in and transaction is performed with different user from the app, also name string of users can be same and it can be set of unknown that can't be hard coded as
def apiUser = "bot"
Is there any call that clearly gives idea that this event creation is via a UI call?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm not sure what do you mean by "Jira is logged in ". Jira will be logged in by many users at any given time , but above function will get you the user who performed the action (it can be api user or any other user).
If you run the above code in console , it will always return the user name you are currently logged in . If the same code gets triggered by an even it will return the api user which triggers that.
getName() or getKey() gets you the user-id which should be unique . it's the getDisplayName() function that gets you the full name which can be many.
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().getKey()
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().getName()
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().getDisplayName()
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.