Sunday, June 15, 2008

How to FTP artifacts in maven2

If there is one word a team should keep in mind when building a CI (Continuous Integration) environment it's Automate, Automate, and Automate (see Production-ready software, on-demand). Most teams, including mine currently, performs their releases manually; creating the branch, incrementing the POMs, uploading the artifacts to a repository, etc. This is one reason I wrote about using the maven release plugin to automate this process. I will say that having a CI server such as Hudson only helps in making automation easier.

My team also creates an official release about once every two months and supports that release anywhere between 1-2 weeks to months. It's also pretty intense during those 1-2 weeks when we have co-workers on-site installing and supporting our software in a completely different timezone and with limited access to the phone and internet.

Over the weekend I wrote a simple maven2 pom to help automate FTP'ing the release artifacts to an FTP server. Last week we created a branch and a job in hudson that builds that branch. After it successfully builds we use the assembly plugin to package our EAR, documentation, SQL files, and everything else into a single folder. In the past, a guy would then manually copy these files to the FTP server, which was used by the on-site team to download the latest artifacts containing improvements and bug fixes. This release we wanted to automate this step to increase our response time for the on-site team.

First Try using GMaven Plugin
I knew that Ant had an FTP task and I love doing Ant in Groovy because its so much easier so I decided to first try the GMaven plugin (maven groovy plugin). It was a short trip since the FTP task is an optional library in Ant and you have to include the jar in your POM, but I could never get the gmaven plugin to recognize the dependency (see MGROOVY-152). Look at the Jira issue attachments if you want to reference my POM as an example. It's too bad I couldn't get this to work because it would have been sweet:
log.info('Entering in ftp script')

def config = [server: 'localhost',
remotedir: '/home/jlorenzen/ftptest',
user: 'ftp',
password: 'ftp'
];

ant.ftp(config) {
fileset(dir: '
/home/jlorenzen/Documents')
}

Second Try Maven AntRun Plugin
I was finally able to get this to work using the maven-antrun-plugin. Here is my POM
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>ftp</id>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<ftp server="localhost"
remotedir="/home/jlorenzen/ftptest"
userid="ftp"
password="ftp">
<fileset dir="/home/jlorenzen/Documents"/>
</ftp>
</tasks>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-commons-net</artifactId>
<version>1.6.5</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>1.4.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

12 comments:

  1. Hi,

    Did you consider using maven site plugin to publish your documentation over ftp?

    Siarhei

    ReplyDelete
  2. great article, I was very impressed about it, wish you would have stayed next share
    kids games
    friv
    unblockedgames
    un show mas

    ReplyDelete
  3. Its really good information, i like your blog post. Thanks for sharing
    Signature:
    i like play happy wheels demo online and play happy wheels games full and game zombie tsunami , retrica apk , retrica download , happy wheels demo , agario

    ReplyDelete
  4. I found a lot of information here to create this actually best for all newbie here. Thank you for this information.
    happy wheels , agario , happywheels , agar ,

    ReplyDelete
  5. Thanks for your sharing. We feel very pleased about that. You should also try their best games with our free today to get the sense of fun that brings. Thank you!
    Juegos de Matar Zombies
    earn to die
    earn to die 2
    earn to die 3
    earn to die 4
    earn to die 1
    earn to die part 2
    earn to die 5
    earn to die 6

    ReplyDelete
  6. First You got a great blog.I will be interested in more similar topics.
    Signature:
    Download retrica app includes more than eighty different filters with many different styles and include retrica , and play zombie tsunami game is the ideal game for anyone who loves the running game genre

    ReplyDelete
  7. Thanks for your sharing. We feel very pleased about that. You should also try their best games with our free today to get the sense of fun that brings. Thank you!
    Vex 3 Game
    Vex 3
    Vex Game
    Juegos de Matar Zombies
    return man 3
    return man 2
    return man

    ReplyDelete
  8. Rousing. I'm set for break out the old earth, myself. Much obliged for sharing.

    shoes online

    ReplyDelete
  9. Thankyou For Informative Post Guide Step By Step

    ReplyDelete