Sshexec-maven-plugin
From Evgeny Goldin
(Redirected from Maven-sshexec-plugin)
Introduction
Some builds don't end up only creating a "*.tar.gz" archive. Sometimes they're required to set up a running system, once a final product archive is ready. In the simplest case, it means copying product archive to a Linux server, unpacking and running it there, before testing it remotely, probably. This operation consists of two steps:
1. Network support of "copy-maven-plugin" allows to copy files to a remote server:
<plugin> <groupId>com.github.goldin</groupId> <artifactId>copy-maven-plugin</artifactId> <version>0.2.5</version> <executions> <execution> <id>deploy-archive</id> <phase>install</phase> <goals> <goal>copy</goal> </goals> <configuration> <resources> <resource> <targetPath>scp://user:password@server:/location</targetPath> <file>${project.build.directory}/finalArchive.tar.gz</file> </resource> <resource> <targetPath>scp://user:password@server:/location</targetPath> <file>${project.basedir}/src/main/scripts/unpack.sh</file> </resource> </resources> </configuration> </execution> </executions> </plugin>
2. "sshexec-maven-plugin" allows to sshexec operations:
<plugin> <groupId>com.github.goldin</groupId> <artifactId>sshexec-maven-plugin</artifactId> <version>0.2.5</version> <executions> <execution> <id>unpack-archive</id> <phase>install</phase> <goals> <goal>sshexec</goal> </goals> <configuration> <runIf>{{ .. }}</runIf> <location>scp://user:password@server:/location</location> <command>chmod +x ./unpack.sh; ./unpack.sh</command> </configuration> </execution> </executions> </plugin>
- Here we assume
"${project.basedir}/src/main/scripts/unpack.sh"is a Linux script containing all logic required to unpack the archive and start up the application. After both of them copied with"copy-maven-plugin"to a remote server,"sshexec-maven-plugin"provides an easy way to run the script. In fact, the script may not be required at all, if you're willing to put all unpacking logic inside<command>. -
<runIf>is an optional argument, it specifies if plugin needs to be run. See"copy-maven-plugin"documentation for more details.
Details
| Provided By | ||
|---|---|---|
| Mailing List | Nabble | |
| Source Code | GitHub | |
| Tests | GitHub | |
| GroovyDoc | <groovydoc>
| |
| Issue Tracker | YouTrack | |
| Build Server | Maven TeamCity | |
| Maven Coordinates |
| |
| Goal |
| |
| Default Phase |
| |
| Maven Repository | Artifactory |
<configuration> reference
| Name | Default value | Description | Example |
|---|---|---|---|
<runIf>
| Controls whether or not plugin should be executed | <runIf>{{ System.getProperty( 'propertyName' ) != null }}</runIf>
| |
<location>
| SCP location to execute commands in "scp://user:password@host:/path"
| <location>scp://user1:password2@host3:/</location>
| |
<commands> / <command>
| ";" or ","-separated commands to execute
|
<!-- Single <command>, ";"-separated --> <command>ls -al; rm -rf directory; unzip file.zip</command> <!-- Single <command>, ","-separated --> <command>ls -al, rm -rf directory, unzip file.zip</command> <!-- <commands> + multiple <command>s --> <commands> <command>rm -rf directory</command> <command>unzip file.zip</command> </commands> | |
<commandsShellSeparator>
| "; "
| Separator to use when sending multiple commands to shell execution | <commandsShellSeparator>;</commandsShellSeparator>
|
<verbose>
| false
| Whether SCP logging should be verbose | <verbose>true</verbose>
|
<echoPwd>
| true
| Whether location should be echoed after connecting | <echoPwd>false</echoPwd>
|
<echoCommands>
| false
| Whether commands should be echoed before executing them on remote host | <echoCommands>true</echoCommands>
|
<keyfile>
| Location of private key to use for key-based authentication. Password should be specified in <location> but it can take any non-empty value, such as "dummy".
| <keyfile>${user.home}/.ssh/id_rsa</keyfile>
| |
<passphrase>
| ""
| Private key passphraze to use for key-based authentication. | <passphrase>myPassPhrase</passphrase>
|
