Yes, you can write code for SR that can reach out to other accessible sites and read data from them.
How are you publishing your CSV? Is it available on a proper URL, or are you looking at non-canonical UNCs like file shares?
Thank you @Nic Brough -Adaptavist- for the reply,
I am not limited of the location of the file, I just want to successfully accessing it.
First I thought to be attached on an issue (attachment), but I couldn't find how to access from there on Cloud, so I put the file on Google Sheets, and tried this code:
import com.opencsv.CSVReader;
@GRAPES(
@grab(group='com.opencsv', module='opencsv', version='5.7.0')
)
def filePath = 'urlFromGoogleSheetsFile'
def reader = new CSVReader(new FileReader(new File(filePath)))
def data= reader.collect { it }.with { rows ->
def header = rows.head()
def dataRows = rows.tail()
dataRows.collect { row ->
[header, row].transpose().collectEntries()
}
}
data.each{row->
// access any data from the row by the name of the header
// for example, row['colHeader'] or row.colHeader
}
..........
But I got this type of exception:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah, ok, reading the file, not a problem with getting it.
SR for Cloud doesn't import extra libraries like that - you'd need to get us (Adaptavist) to add it to the server running your scripts.
Have a look at https://library.adaptavist.com/entity/bulk-update-the-value-of-a-custom-field-on-jira-issues - that tells you how to read a remote file, but you're going to have to write code to parse it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I checked the link, but it shows me how to update the value of a Custom Field on Jira Issue.
Also the idea is to reach some csv file through SR on Cloud, no matter on which location is, so it can read what is inside the file and do some stuff inside Jira?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, sorry, it was only supposed to be showing you another way to read a file, but I didn't say that.
You will need to code something that can parse the files you are reading.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Okey. the code for parsing a file is not a problem, Firstly is there some documentation/example how to reach the file from SR ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Ivana Srebrenova Have you had any luck with reading the CSV file and get this implemented. We have a similar requirement. Any help would be much appreciated.
Thanks,
Ojase
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Ojase Emmanuval since this implementation was intended for cloud this solution with accessing and reading a CSV file on Jira cloud with Script Runner was not possible, because of limitation on which libraries and packages can be imported there and also unfortunately Atlassian does not provide access to the file system. On server it is possible.
As a workaround we use the Import/Export option: https://support.atlassian.com/jira-cloud-administration/docs/import-data-from-a-csv-file/ and worked with automation.
I think this will be helpful for you too.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Ivana Srebrenova Thanks for the reply. What you mean by "worked with automation". Were u able to make use of JIRA automations to do anything similar?
Thanks,
Ojase
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.