Like @zerodiff suggested there seems to be a number of ways to do this via Hudson but they all seemed to be brittle and difficult to maintain when managing a large number of projects. I instead used Maven's wagon plugin to implement the deployment via Maven instead of via Hudson.
The configuration I used in the maven projects:
<properties>
<!-- Deploy -->
<dev.server.hostname>192.168.1.1</dev.server.hostname>
<application.name>test-application</application.name>
<!-- Deploy -->
</properties>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>1.0</version>
</extension>
</extensions>
</build>
<profiles>
<profile>
<id>hudson</id>
<activation>
<property>
<name>env</name>
<value>hudson</value>
</property>
</activation>
<build>
<filters>
<filter>src/main/filters/${env}-linux.properties</filter>
<filter>src/main/filters/${env}.properties</filter>
</filters>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0-beta-5</version>
<executions>
<execution>
<id>dev-deploy</id>
<phase>deploy</phase>
<goals>
<goal>upload</goal>
</goals>
<configuration>
<fromDir>${project.build.directory}</fromDir>
<includes>${project.build.finalName}.jar</includes>
<url>scp://${dev.server.hostname}/</url>
<toDir>/opt/${application.name}</toDir>
<serverId>dev-deploy-server</serverId>
</configuration>
</execution>
<execution>
<id>execute-dev-deploy-commands</id>
<phase>deploy</phase>
<goals>
<goal>sshexec</goal>
</goals>
<configuration>
<url>scp://${dev.server.hostname}/</url>
<serverId>dev-deploy-server</serverId>
<commands>
<command>sudo /etc/init.d/${application.name} stop</command>
<command>sleep 2</command>
<command>sudo /opt/${application.name}/relink.sh ${project.build.finalName}.jar</command>
<command>sudo /etc/init.d/${application.name} start</command>
</commands>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
In my maven settings.xml, I have the credentials for the dev-deploy-server:
<server>
<id>dev-deploy-server</id>
<username>hudson_bot</username>
</server>
With the Maven plugin in Hudson, I added the "Invoke Maven 3" Build directive and:
- Goals: clean deploy
- Properties: env=hudson
Finally I set up the security between the two servers so that "hudson_bot" could scp to the dev-deploy-server and gave hudson_bot sudoer NO_PASSWD privileges to the two mentioned scripts in the ssh execute element.