Internal Repository – Deploy artifacts with SSH

Uploading to the repository

In the settings.xml file define the connection details for the remote repository (using the <server> tag)

<server>
...
  <id>ssh-repository</id>
  <username>${user}</username>
  <password>${password}</password>
  <privateKey>C:\Documents and Settings\Beppe\Application Data\SSH\UserKeys\cvs.pub</privateKey>
  <filePermissions>664</filePermissions>
  <directoryPermissions>775</directoryPermissions>
...
</server>

Enter the credentials of the user performing the SSH access (ensure the right privileges are assigned ), the full path to the private key (tag <privateKey>) and file/folder permissions as above (required to deploy the artifacts on the server).

Deploy the artifact

Finally deploy the artifact to the internal repository:

mvn deploy:deploy-file
-DgroupId=com.mycompany -DartifactId=myLib -Dversion=1.0.0 \
-DgeneratePom=true -Dpackaging=jar -Dfile=target/mylib.jar \
-DrepositoryId=ssh-repository -Durl=scp://dev.mycompany.com/vol1/data/m2

The deploy command will upload the artifact to the internal repository generating the pom.xml descriptor according to the command line parameters.

Using the IDE

To deploy the artifact from within the Java IDE (instead of using command line) add the following to the pom.xml

<distributionManagement>
  <repository>
    <id>ssh-repository</id>
    <name>Repository for Maven artifacts</name>
    <url>scp://dev.mycompany.com/vol1/data/m2</url>
  </repository>
</distributionManagement>

You can then run the deploy goal from within the IDE.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: