Created
June 24, 2015 07:02
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Well-played!