Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,460,434
Community Members
 
Community Events
176
Community Groups

groovy.lang.MissingPropertyException: No such property: issue for class: Script139

Deleted user Sep 27, 2017

 I'm attempting to create a Confluence page whenever a user makes a new task/story in JIRA. The two applications, JIRA and Confluence, are linked together.

 

In the process I'm trying to learn Script Runner. However, it appears not even Adaptavist's own examples are compiling? A direct copy/paste of their example provides the error of:

 

groovy.lang.MissingPropertyException: No such property: issue for class: Script139 at Script139.run(Script139.groovy:24)


Am I doing something wrong here? I'm running it in the JIRA script console, at..

/plugins/servlet/scriptrunner/console?section=script_console

1 answer

Hi Cristian,

This script is written to be used as a post function, where the issue provided in the binding. 

If you want to run it via the script console then replace line 25 with 

import com.atlassian.jira.component.ComponentAccessor


def issue = ComponentAccessor.issueManager.getIssueByCurrentKey("ISSUEKEY-1")

regards, Thanos

Where is ComponentAccessor imported from?

And what do you mean by post function; How are these tested(and deployed)?

As per running it in the console, your solution wouldn't work, as the rest of the code tries to access properties within issue(which will throw an error) :)


Hi Cristian,

I updated the script in order to include the ComponentAccesso import. 

PostFunctions is a key concept in Jira's workflows - Advanced workflow configuration

Script Runner offers few built in post functions. The script you found is for a custom script post function.

What he script actually does is that is trying to get some issue properties and create a confluence page with them. So the script in the example you found is getting the issue which is in the transition. In script console there is no issue in transition. 

Therefore you have to get a known issue, by key, using the issueManager. The rest of the script remains the same. Did you try to run it ? You have to make sure that you set up an application link between your JIRA and Confluence instances 

Hope what I say makes sense.

regards, Thanos

It makes some sense - I'm not new to groovy, but i am to the atlassian stack :-) Your initial scripts works(at least for syntax, i have some problems with confluence link I think) - so there's something to play around with.

 

At least now, I get "You're not allowed to view that space, or it does not exist" with a 403 thrown back; but it is linked correctly on both sides and says CONNECTED. So it's a bit strange. 


Deleted user Sep 28, 2017

Some elaboration:

I have created a confluence space, the space key is "SD"

I have created a sample JIRA project, key is BEC.

 

I set the issuekey to BEC-10(it exists) and space to "SD" as in your sample code - also exists.


Now I get this response:

 

{"statusCode":500,"data":{"authorized":false,"valid":true,"errors":[],"successful":false},"message":"com.atlassian.confluence.api.service.exceptions.ServiceException: java.lang.UnsupportedOperationException: Cannot convert from null to storage"}


Any idea what it could mean? 

Edit your code so to include in the params

represenation: "storage", something like: 

def params = [
type: "page",
title: pageTitle,
space: [
key: "TEST" // set the space key - or calculate it from the project or something
],
body: [
storage: [
value: writer.toString(),
representation: "storage"
]
]
]

regards, Thanos

Deleted user Sep 28, 2017

Where do you declare the writer variable and what is it? 

Deleted user Sep 28, 2017

I got it working by adding the pageBody instead of writer. So that's nice.

I'm a bit confused; this works in the console now which is good. What would the steps to "deploy" this on the JIRA solution be?

So that f.e. a user creates a story, and the confluence page is then created by the script with the information. I can't seem to dig this out of the documentation?

Thanks :) 

Hi Cristian,

So in your scenario the script should be a custom script post function on the Create step. And in that case your issue will be

Issue issue = issue

as it is in the original script. Which actually means 

"Use the issue in transition"

In order to see hoe to set up a post function, follow the links I sent on my second comment. 

Shout if you need further assistance. 

Kind regards, 

Thanos 

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events