My input is a csv file full with issues, i want to import them to my instance, without a manual task
This has two parts,
One, Jira provide wonderful CSV import functionality in admin section, you can use that, it will prevent you from lots of hassle.
Two, if you want to import it via script/terminal rather then using just curl use any scripting language, like node, python etc.
Here is node sample that I used few months back to create some test data.
CSV structure was,
projectkey,issuetypeid,summary
And node file was like this,
// This code sample uses the 'request' library:
// https://www.npmjs.com/package/request
var request = require("request");
//file stream
var fs = require("fs");
//csv parser
var parse = require("csv-parse");
var fileName = "data.csv"; //name of csv file
var csvData = [];
fs.createReadStream(fileName)
.pipe(parse({ delimiter: ":" }))
.on("data", function(csvrow) {
//console.log(csvrow);
//do something with csvrow
csvData.push(csvrow);
})
.on("end", function() {
//do something wiht csvData
//console.log(csvData);
});
csvData.forEach(function(data) {
var bodyData = `{
"update": {},
"fields": {
"summary":"${data.summary}",
"issuetype":{
"id": "${data.issuetypeid}"
},
"project": {
"key": "${data.projectkey}"
}
}
}`;
console.log(data);
console.log(bodyData)
var options = {
method: "POST",
url: "<JIRA_BASE_URL>/rest/api/2/issue",
headers: {
Authorization: 'Bearer <BASE64_TOKEN>'
Accept: "application/json",
"Content-Type": "application/json"
},
body: bodyData
};
request(options, function(error, response, body) {
if (error) throw new Error(error);
console.log(
"Response: " + response.statusCode + " " + response.statusMessage
);
console.log(body);
});
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.