Is there a list of parameters that are passed into a Post Function? I assume that an Issue object is. Anything else?
Can you pass parameters to a Post Function in addition to those listed above?
For example, we'd like the same "block" of code to do 2 related things but control the behavior by a parameter.
There's no place in Jira to pass in parameters to a post-function.
The code in a post-function has access to the whole internal Jira API and gets the "mutable issue" object representing the issue being transitioned and the session data from the account making the transition, but that's all. If you want other data, your code will have to fetch it.
Thanks, @Nic Brough -Adaptavist-
Where would be one of the locations that that data could be fetched from?
For example, we have Groovy code to get/set the value of a Custom Field. It's essentially the same code with only the name of the Custom Field different. We were hoping to pass the Custom Field name in as a parameter.
There doesn't seem to be an easy way to solve this problem with Jira/ScriptRunner (or my perspective isn't wide enough - I'm open to suggestions).
Thanks, Nic.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can fetch from anywhere really. Workflow functions are all aware of the issue being worked on (and hence most of the system fields directly held on them like summary, resolution, type etc), but you can go fetch custom-fields for them as well.
But there is nowhere to store your parameters. If you want the same post-function to behave differently given different data, you have to put the code that makes that decision into the post-function.
You could easily do something like "if issue type X, then read custom-field-a, else read custom-field-b". But there's nowhere to store "my parameter". The closest I can get to a parameter is a workflow or transition property, but that's still going to be hard-coded to the transition in the workflow.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks, @Nic Brough -Adaptavist-
But that means that they all have to be inline scripts rather than stored in files on the server. I can customize the inline scripts by having internal variables to change behavior but if I did that with files, I'd end up with hundreds of separate files and it would be a mess, hence the reason I was asking for parameters that I could pass into (code in a file).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am a bit lost on what you mean there.
There is no difference between an inline script and a file based script - when one is called, Jira reads the script from a field or from a file. It's the same block of text however you do it.
There is nothing to stop you reading a file in a script, but it won't contain "parameters" from the Jira process, unless you wrote it out in a previous post-function, which is pointless, you might as well just work out what goes into it at the start of the script and not bother writing it, just use the data direct.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There is no problem in working with files, when you call a postfunction you it has access to every field that is defined in the issue, you can create a field called parameter or something like that and you give it the value in the issue (I guess your parameters will be based in issuetype, component, version, project or some other data that you have in the issue your are working with so you could easily automate those fields value somewhere in the workflow)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
with script runner you can access every custom field defined in the scope of the project (usually almost everyone).
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cField = customFieldManager.getCustomFieldObject(xxxxx) //being xxxxx the id of the field
// or
// def cField = customFieldManager.getCustomFieldObjectByName('custon field name')
def cfValue = cField.getValue(issue)
//or
// def cfValue = issue.getCustomFieldValue(cField)
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.
@Sreenivasaraju P I looked at that creating-workflow-extensions page and it is so far beyond where I'm at that it wasn't much help. In addition, I didn't see any reference to passing parameters into a Post Function in an Inline Script.
We're looking for functionality that works a bit like passing arguments to a shell script or C program where they can be processed via argc and argv.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you developing your own post function ?
You can pass any parameter to the post function. You can configure while adding the post function.
Using plugin factory , you can configure the required parameters.
You can refer below link
https://developer.atlassian.com/server/jira/platform/creating-workflow-extensions/
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.