Iam new to atlassian stack
I've been trying to write custom scripts for some purposes using script runner, but iam stuck.
I've been trying to get code from adaptivist library and make some changes and make it work somehow even after not knowing or have good knowledge about the functions iam just uisng them and making it work somehow .
I have some coding background so iam feeling a little insecure to write code this way , so i was trying to explore through jira java api , but it's overwhelming , iam not making any progress in it .
can any of you guys explain how you go about exploring jira java api or how you write code for script runner like how to figure out what package to import what function to use etc.
Hi and Welcome!
Are you familiar with pom-files, working with an IDE ...? If so, this might help.
What I recommend is installing the Atlassian SDK:
https://developer.atlassian.com/server/framework/atlassian-sdk/
Then from that framework you can generate an Atlassian plugin skeleton:
https://developer.atlassian.com/server/framework/atlassian-sdk/create-a-helloworld-plugin-project
This will generate a plugin project which you can open with an IDE for example IntelliJ. If you create .groovy files here you will get code completion for the Jira API! The version of the API will be the one mentioned in the POM-file and can be changed:
Hope this helps!
Regards,
Jeroen
Hi thank you for your answer, but if iam not wrong , isn't this for like when you are trying extend jira functionalities and make a separate app.
What i was asking was on how to come up with scripts or how to understand the jira java api , the link i have mentioned below , how to navigate and understand it
https://docs.atlassian.com/software/jira/docs/api/9.6.0/
Now iam only able to modify the code like the one below
//Code
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
def issueService = ComponentAccessor.issueService
def issueManager = ComponentAccessor.issueManager
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def issueKey = 'TEST-1'
def issue = issueManager.getIssueObject(issueKey)
assert issue: "Could not find issue with key $issueKey"
def inputParams = issueService.newIssueInputParameters().tap {
it.setSummary('Hello ScriptRunner!')
}
def validation = issueService.validateUpdate(user, issue.id, inputParams)
if (validation.isValid()) {
def issueResult = issueService.update(user, validation, EventDispatchOption.ISSUE_UPDATED, false)
if (issueResult.isValid()) {
"${issue.key} updated"
} else {
log.error(issueResult.errorCollection.errors)
'Failed updating the issue'
}
} else {
log.error(validation.errorCollection.errors)
'Validation failed.'
}
//Code
this code now works in console , but if i try to make it work in listener i will have to use different code , use different functions , the thing is iam not getting what functions or packages
This is where iam stuck.
Thank you for answering the questions but if you can provide any guidance on i can how about it , that would help me alot
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi!
Indeed, the plugin skeleton that is generated is for extending Jira with an app, but ... If you just create groovy files within this skeleton you will be able to leverage the Code completion that comes with the Atlassian SDK, thus ... you can modify your script there in the IDE, inspecting the entire Jira API.
When your script is ready just place it inside the Jira UI where you want to use it. The generated app skeleton is just there to create an environment where you can make use of the API support while developing scripts.
Regards,
Jeroen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@raghuvarmaofficial are you able to find the answer of your question?
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.