The below simple example shows how to upload the maven build artifacts to the Jfrog artifactory.
1. First download the Jfrog OSS artifactory from https://jfrog.com/open-source/ link and download ZIP to your computer.
2. Unzip the file and run the artifactory.bat from the bin folder inside the application.
3. Once artifactory is run, then go to the browser and hit http://localhost:8080 or your customized port location
4. After the artifactory is up and running, create the artifact repository one for snapshots and one for releases. For example maven-releases for releases and maven-snapshots for snapshots repository.
5. In your maven project pom.xml put the distribution management as shown below
<distributionManagement>
<repository>
<id>releases</id>
<url>http://localhost:8080/artifactory/maven-releases</url>
<name>maven-releases</name>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://localhost:8080/artifactory/maven-snapshots</url>
<name>maven-snapshots</name>
</snapshotRepository>
</distributionManagement>
6. Now in the maven's setting ${MAVEN_HOME}/conf/settings.xml, set the credentials for the artifactory inside servers setting as:
<server>
<id>releases</id>
<username>user</username>
<password>pass</password>
</server>
<server>
<id>snapshots</id>
<username>user</username>
<password>pass</password>
</server>
7. Now in your maven project's root start the SNAPSHOT deployment using the command:
$ mvn clean package deploy
-this command will deploy the artifacts generated (usually the jars) to the maven-snapshots of the artifactory
8. To deploy the RELEASE we would need to do
$ mvn release:clean release:prepare release:perform
- for this to work, we would also need to hook up the source code repository in scm element in the pom.xml file as:
<scm>
<connection>scm:git:https://github.com/your-accountt/your-project.git</connection>
<url>http://github.com/your-account/your-project</url>
<developerConnection>scm:git:https://github.com/your-account/your-project.git</developerConnection>
<tag>HEAD</tag>
</scm>
you can also connect to other source code repository instead of the git repository. The credential can also be provided same as for the artifactory in the maven's settings.xml file.
we would probably also need to add the following plugin inside the plugins in the pom.xml in-order to make this work
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<tagNameFormat>v@{project.version}</tagNameFormat>
<autoVersionSubmodules>true</autoVersionSubmodules>
</configuration>
</plugin>
9. If everything is OK, then the maven project should build, upload the artifacts to Artifactory's releases repository and update the source code in the scm repository.
10. We can also deploy to the Nexus Repository Manager OSS maven repository in the same way. Follow the link https://www.sonatype.com/download-oss-sonatype to download the Nexus Repository.
That's All!
1. First download the Jfrog OSS artifactory from https://jfrog.com/open-source/ link and download ZIP to your computer.
2. Unzip the file and run the artifactory.bat from the bin folder inside the application.
3. Once artifactory is run, then go to the browser and hit http://localhost:8080 or your customized port location
4. After the artifactory is up and running, create the artifact repository one for snapshots and one for releases. For example maven-releases for releases and maven-snapshots for snapshots repository.
5. In your maven project pom.xml put the distribution management as shown below
<distributionManagement>
<repository>
<id>releases</id>
<url>http://localhost:8080/artifactory/maven-releases</url>
<name>maven-releases</name>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://localhost:8080/artifactory/maven-snapshots</url>
<name>maven-snapshots</name>
</snapshotRepository>
</distributionManagement>
6. Now in the maven's setting ${MAVEN_HOME}/conf/settings.xml, set the credentials for the artifactory inside servers setting as:
<server>
<id>releases</id>
<username>user</username>
<password>pass</password>
</server>
<server>
<id>snapshots</id>
<username>user</username>
<password>pass</password>
</server>
7. Now in your maven project's root start the SNAPSHOT deployment using the command:
$ mvn clean package deploy
-this command will deploy the artifacts generated (usually the jars) to the maven-snapshots of the artifactory
8. To deploy the RELEASE we would need to do
$ mvn release:clean release:prepare release:perform
- for this to work, we would also need to hook up the source code repository in scm element in the pom.xml file as:
<scm>
<connection>scm:git:https://github.com/your-accountt/your-project.git</connection>
<url>http://github.com/your-account/your-project</url>
<developerConnection>scm:git:https://github.com/your-account/your-project.git</developerConnection>
<tag>HEAD</tag>
</scm>
you can also connect to other source code repository instead of the git repository. The credential can also be provided same as for the artifactory in the maven's settings.xml file.
we would probably also need to add the following plugin inside the plugins in the pom.xml in-order to make this work
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<tagNameFormat>v@{project.version}</tagNameFormat>
<autoVersionSubmodules>true</autoVersionSubmodules>
</configuration>
</plugin>
9. If everything is OK, then the maven project should build, upload the artifacts to Artifactory's releases repository and update the source code in the scm repository.
10. We can also deploy to the Nexus Repository Manager OSS maven repository in the same way. Follow the link https://www.sonatype.com/download-oss-sonatype to download the Nexus Repository.
That's All!