sftp resolver

Handle latestyes
Handle publishyes

This resolver can be used when your ivy repository is located on a server accessible via sftp. The secured nature of sftp and its widespread implementation on most *nix servers makes this resolver a very good candidate in an enterprise environment. since 1.4 If your server supports ssh but not sftp, there is also an ssh resolver.

Note that sftp is also supported by vfs, so you can use a vfs resolver instead. The advantage of this resolver is that you have a better control over authentication, it can prompt for username/password credentials, or you can use private/public key authentication, which is not possible with the vfs resolver. When it prompts for username/password, it uses a Swing dialog, which is not possible in a headless environment. If you want to prompt for the credentials on the command line, use ant input task for example before calling ivy.

All necessary connection parameters can be set here via attributes.
However all attributes defined in the pattern url of the resolver will have higher priority and will overwrite the values given here. To specify connection parameters in the pattern, you have to specify a full url and not just a path as pattern.
e.g. pattern="/path/to/my/repos/[artifact].[ext]" will use all connection parameters from this class
e.g. pattern="sftp://myserver.com/path/to/my/repos/[artifact].[ext]" will use all parameters from the attributes with the exception of the host, which will be "myserver.com"
e.g. pattern="sftp://user:geheim@myserver.com:8022/path/to/my/repos/[artifact].[ext]" will use only the keyFile and keyFilePassword from the attributes (if needed). Rest will come from the url.

Note that the authentication features of this resolver are exactly the same as the ssh resolver. Choosing between the two is often a matter of server implementation. If your server supports sftp, usually it's preferrable.

Internally this resolver relies on jsch as ssh client, which is a popular java ssh client, used for example in eclipse.


This resolver shares the common attributes of standard resolvers.
userThe username to provide as credential No, defaults to username given on the patterns, or prompt if none is set
userPasswordThe password to provide as credential No, defaults to password given on the patterns, or prompt if none is set
keyFilePath to the keyfile to use for authentication No, defaults to username/password authentication
keyFilePasswordthe password used to protect the key file No, will prompt for password if keyFile authentication is used and if it is password encrypted
hostThe host to connect to No, defaults to host given on the patterns, fail if none is set
portThe port to connect to No, defaults to 22

Child elements

ivydefines a pattern for ivy files, using the pattern attribute 0..n
artifactdefines a pattern for artifacts, using the pattern attribute 1..n


<sftp user="myuser" host="myhost.com">
<ivy pattern="/path/to/ivy/[module]/ivy.xml"/>
<artifact pattern="/path/to/[organisation]/[module]/[artifact].[ext]"/>
Will connect to myhost.com using myuser and prompt for the password.

<sftp user="${myuser}" userPassword="${my.password}" host="myhost.com">
<ivy pattern="path/to/ivy/[module]/ivy.xml"/>
<artifact pattern="path/to/[organisation]/[module]/[artifact].[ext]"/>
Will connect to myhost.com using user and password provided with ivy variables.

<ivy pattern="sftp://user:geheim@yourserver.com:8022/path/to/repos/[module]/[revision]/ivy.xml"/>
<artifact pattern="sftp://user:secret@myserver.com:8022/path/to/my/repos/[artifact].[ext]"/>
Will connect to yourserver.com on port 8022 with user 'user' and password 'geheim' for authentication for ivy files, and to myserver.com on port 8022 using user 'user' and password 'secret' for the artifacts.

<sftp keyFile="path/to/key/file" keyFilePassword="${password}">
<ivy pattern="sftp://user@yourserver.com:8022/path/to/repos/[module]/[revision]/ivy.xml"/>
<artifact pattern="sftp://user@myserver.com:8022/path/to/my/repos/[artifact].[ext]"/>
Will connect to yourserver.com on port 8022 with user 'user' and use keyFile path/to/key/file for keyFile and the value of password variable for keyFilePassword authentication for ivy files, and to myserver.com on port 8022 using user 'user' with the same keyFile/keyFilePassword pair for the artifacts.