Write to activity stream from groovy script

Dominik Heßmann July 9, 2014

Hi,

i want to write my own 'messages' to the issue activity stream from a groovy script. Can anybody provide an example?

Greetings, Dominik.

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 10, 2014

As well as the rest API you can use the java API... here is a simple script example for adding an item to the logged in user's activity stream that I adapted from Atlassian;s tutorial:

https://gist.github.com/jechlin/dd5a9fe43f104494ea2a

Oh - that will only work in the latest version of the plugin, 3.0.

Dominik Heßmann July 13, 2014

Hi Jamie, your sample works like a charm! Thanks.

In the altalssian sample the issue link gets highlighted. I've tried different urls and urlStings but the issue woun't turn into a link. Any idea on that?

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 14, 2014

Are you talking about in this screenshot? https://developer.atlassian.com/display/DOCS/Adding+Activities+to+a+Third+Party+feed+with+the+Java+API

You can use html so you can format what's shown how you like... you can view the html in the browser to see what you need to write for a blue bg.


Dominik Heßmann July 14, 2014

Yes, like in this example. When i use the code provided on the page, my issue did not turn into a link. And the message did not appeare on the issues activity tab.

My second problem is that when i'm running into an error, nothing is display. I use

log.setLevel(org.apache.log4j.Level.DEBUG)

in my script but when calling the activity object, no messages/stack traces are displayed.

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 15, 2014

If you look closely at the pictures there are two items in the activity. The first one, with the link, is not from the tutorial plugin. The second one, doesn't have the link.

If you want links you can write them in html:

some(html(user.getDisplayName()+" <a href='...'>did something</a> "))

> my script but when calling the activity object, no messages/stack traces are displayed

which log are you looking in?

Dominik Heßmann July 15, 2014

I've seen a video 'Get in the flow with Atlassian Streams' from 2011. Near 16:50 the speaker shows how to associate the stream entry with the Issue Activity stream AND the project stream with no html. I thought this must be possible in the Java API and the REST API.

Christof Hurst August 28, 2017

Hi Jamie,

thanks for your script. This will add activity to the activity stream.

But my problem is that some changes are not displayed in the issue history. How can I add my changes there?

Best regards

Christof

0 votes

You can use the rest API for streams then use something like http://groovy.codehaus.org/modules/http-builder/doc/rest.html... hope that helps you a bit

TAGS
AUG Leaders

Atlassian Community Events