You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I want to check when a release dates is updated, and return the user who updated the version in addition to the previous and updated date.
The audit log can show these data but I want to use scriptrunner to retrieve the data so i can store it in variables and perform function and conditions.
So is there a way to retrieve the data?
Thanks in advance
Hi @S A
If you want to retrieve data from the Audit Logs via ScriptRunner, the best approach would be via the REST Endpoint.
Below is a sample working code for your reference:-
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
import groovy.json.JsonBuilder
import groovy.transform.BaseScript
import groovyx.net.http.HttpResponseDecorator
import groovyx.net.http.RESTClient
import javax.servlet.http.HttpServletRequest
import javax.ws.rs.core.MultivaluedMap
import javax.ws.rs.core.Response
@BaseScript CustomEndpointDelegate delegate
getAuditRecords { MultivaluedMap queryParams, body, HttpServletRequest request ->
def applicationProperties = ComponentAccessor.applicationProperties
def hostUrl = applicationProperties.getString('jira.baseurl')
def username = 'admin'
def password = 'q'
def path = '/rest/api/2/auditing/record'
final def headers = ['Authorization': "Basic ${"${username}:${password}".bytes.encodeBase64()}", 'Accept': 'application/json'] as Map
def http = new RESTClient(hostUrl)
http.setHeaders(headers)
def resp = http.get(path: path) as HttpResponseDecorator
if (resp.status != 200) {
log.warn 'Commander did not respond with 200 for retrieving project list'
}
Response.ok(new JsonBuilder(resp.data).toPrettyString()).build()
}
Please note that the sample working code above is not 100% exact to your environment. Hence, you will need to make the required modifications.
Below is a screenshot of the REST Endpoint configuration:-
Below is the expected output:-
I hope this helps to answer your question. :-)
Thank you and Kind regards,
Ram
Hello Ram,
Thank you for responding it's very helpful.
Although I would like to ask few questions, now the purpose of retrieving the data is to try to restrict the edit on Versions specifically the release dates. first thing I considered is to retrieve the data from the audit log and then perform the condition of the users allowed ...etc.
is there another approach where I can accomplish that?
Thanks again.
Best Regards,
SA
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @S A
If you aim to get the details from the versions to restrict them, you don't need to go into the Audit Log.
Instead, you could just get the information directly from the Version History or even from the issue.
There are a couple of approaches discussed earlier, in this Community Discussion as well as this Community Discussion.
You could just do the following:-
issue.fixVersions*.releaseDate
to get the release date of a version.
I hope this helps to answer your question. :-)
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @S A
Has your question been answered?
If yes, could you please accept the answer?
Thank you and Kind regards,
Ram
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.