Using Expect to Work Around CVS SSH Checkout
Pragmatic Programmer Stuart Holloway said in a tweet recently, “Anybody can be agile in a green field. Show me your 3rd, 4th, and 5th releases.” Well, we've been maintaining Oracle Mojarra JSF for 32 releases and, we’ve found hudson a completely invaluable tool for maintaining agility as the technology matures and requires maintenance across all the versions we've ever released. Unfortunately, project hygiene has been difficult to maintain across all the code lines, and the JSF 1.2 branch hasn't had a working hudson job in several years. This blog entry shares a little tip I uncovered while re-activing the Mojarra JSF 1.2 job.
Mojarra JSF 1.2 is maintained in CVS because it is not economically viable to move it to a more recent version control system. As such, it must use CVS_RSH. More recent versions of hudson have support for this, but for some reason I haven't been able to get it working with the java.net cvs server. I used a combination of perl and expect to get the checkout working.
I had to download and install expectperl from <http://sourceforge.net/projects/expectperl/> and the IO::Tty perl module from <http://search.cpan.org/~toddr/IO-Tty/Tty.pm> This little perl script successfully does the cvs update, even with the ssh password prompting.
- #!/usr/bin/perl
- use Expect;
- $ENV{"CVSROOT"} = ":ext:8bit@java.net/cvs/javaserverfaces-sources~cvs-repository";
- unless ($cvs->expect(30, "Enter passphrase for key '/files/hudson_local/.ssh/id_rsa':")) {
- }
- unless ($cvs->expect(300, "cvs update: Updating www/legal/jsf-cddl")) {
- }
This enables me to quickly get the Mojarra JSF 1.2 hudson job working again without upgrading hudson or messing with any other configuration nonsense.
Technorati Tags: edburns