Skip to content

Instantly share code, notes, and snippets.

@tomaslin
Created October 4, 2011 15:56
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomaslin/1262005 to your computer and use it in GitHub Desktop.
Save tomaslin/1262005 to your computer and use it in GitHub Desktop.
This is a groovy file ( http://groovy.codehaus.org/ ) that will import your Pivotal Tracker stories into your Trello board. It works with an empty board and will add stories to the first list.
@Grapes([
@Grab("org.codehaus.geb:geb-core:0.6.0"),
@Grab("org.seleniumhq.selenium:selenium-firefox-driver:2.4.0"),
@Grab("net.sf.opencsv:opencsv:2.0")
])
import geb.Browser
import au.com.bytecode.opencsv.*
def fileLocation = 'secret_escapes_20111004_1436.csv' // the location of your csv file. You can go to your pivotal board and do an export to CSV.
def trelloBoard = 'https://trello.com/board/myboard/4e8b24353fadsa0251ce8'
def trelloUserName = 'username'
def trelloPassword = 'password'
// firefox 7 is not supported yet by selenium, we use the version here - http://download.mozilla.org/?product=firefox-6.0.2&os=linux&lang=en-US
System.setProperty( "webdriver.firefox.bin", "/home/tomas/Downloads/firefox/firefox")
try{
Browser.drive {
go 'https://trello.com/login'
$('#email-login').value( trelloUserName )
$('#password-login').value( trelloPassword )
$('input[type=submit]').click()
}
// web driver throws a stale element exception
} catch( Exception e ){
}
Browser.drive{
def storiesAdded = 0
boolean firstLine = true
CSVReader reader = new CSVReader(new FileReader(fileLocation));
String[] nextLine;
go trelloBoard
while ((nextLine = reader.readNext()) != null)
{
/*
next Line parameters in our export are
0 Id
1 Story
2 Labels
3 Iteration
4 Iteration Start
5 Iteration End
6 Story Type
7 Estimate
8 Current State
9 Created at
10 Accepted at
11 Deadline
12 Requested By
13 Owned By
14 Description
15 URL
*/
if( storiesAdded == 25 ){
go trelloBoard
}
def( title, description, requestedBy, labels ) = [ nextLine[1], nextLine[14], nextLine[12], nextLine[2] ]
def existingStoryCount = $( 'h3.list-card-title a' ).size()
try{
waitFor( 15 ){ $( 'textarea[class=new-card]' ).first().displayed }
def textArea = $('textarea[class=new-card]').first()
textArea.click()
waitFor( 15 ){ $( 'input[value=Add]' ).displayed }
textArea.value( "PV${ storiesAdded }: ${ title }" )
$( 'input[value=Add]' ).click()
} catch (Exception e) {
println "PV${storiesAdded} error setting title \n ${title}"
}
try{
waitFor(30){ $( 'h3.list-card-title a', text: startsWith( "PV${ storiesAdded }:" ) ).displayed }
$( 'h3.list-card-title a', text: startsWith( "PV${ storiesAdded }:" ) ).click()
waitFor( 15 ){ $( 'div.window' ).displayed }
waitFor( 15 ){ $( 'a.js-edit-desc' ).displayed }
$( 'a.js-edit-desc' ).first().click()
waitFor( 15 ){ $( 'input.js-save-edit' ).displayed }
$( 'div.card-detail-edit textarea' ).value( "${description}\r\nRequested By: ${requestedBy}\r\n Labels: ${labels}" )
$( 'input.js-save-edit' ).click()
$( 'a.js-close-window' ).click()
waitFor( 15 ){ !$( 'div.window' ).displayed }
} catch( Exception e ){
println "PV${storiesAdded} error setting description\n ${description}\r\nRequested By: ${requestedBy}\r\n Labels: ${labels}"
}
storiesAdded++
}
println "Imported ${ storiesAdded } stories"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment