Skip to content

Instantly share code, notes, and snippets.

@danistrebel
Created June 24, 2015 07:02
Show Gist options
  • Save danistrebel/3d80caf2f2270d76ba3e to your computer and use it in GitHub Desktop.
Save danistrebel/3d80caf2f2270d76ba3e to your computer and use it in GitHub Desktop.
Parses a Jira XML export and generates Json objects for POSTing them to the Github API
object ParseJiraIssues extends App {
val pathToXMLExport = args(0)
val issues = scala.xml.XML.loadFile(pathToXMLExport)
case class Issue(title: String, summary: String, description: String,
reporter: String, assignee: String,
created: String) {
def toJson = {
s"""{
|"title":"$title",
|"body":"<div<b>$summary</b></div><div>$description</div><div>Created: $created</div>",
|"assignee":"$assignee",
|"labels":["JIRA Mirgrated"]
|}""".stripMargin
}
}
val allIssues = for {
issue <- (issues \\ "item")
} yield {
val title = (issue \ "title").text
val summary = (issue \ "summary").text
val description = (issue \ "description").text
val reporter = (issue \ "reporter").text
val assignee = (issue \ "assignee").text
val created = (issue \ "created").text
Issue(title, summary, description, reporter, assignee, created)
}
allIssues.reverse.foreach(issue => println(issue.toJson))
}
@mykelalvis
Copy link

Well-played!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment