Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploy from Maven to JFrog Artifactory

I have downloaded and installed JFrog Artifactory community edition on a virtual machine.

from my host machine, I am able to see the JFrog admin console when I do http://build.local:8081/. I created a test user in Artifactory and granted the user all the rights

enter image description here

On my host machine I create a java maven project. My POM.xml looks like

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.abhi</groupId>
    <artifactId>HelloWorld</artifactId>
    <version>1.0-SNAPSHOT</version>
    <distributionManagement>
        <snapshotRepository>
            <id>MyJFrog</id>
            <name>MyJFrogArtifactory</name>
            <url>http://build.local:8081/libs-snapshot-local</url>
        </snapshotRepository>
    </distributionManagement>
</project>

Changed my ~/.m2/settings.xml

<servers>
  <server>
    <username>testuser</username>
    <password>testpassword</password>
    <id>MyJFrog</id>
  </server>
</servers>

But still when I do mvn deploy -e I get error

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project HelloWorld: Failed to deploy artifacts: Could not transfer artifact com.abhi:HelloWorld:jar:1.0-20151013.153708-1 from/to MyJFrog (http://build.local:8081/libs-snapshot-local): Access denied to: http://build.local:8081/libs-snapshot-local/com/abhi/HelloWorld/1.0-SNAPSHOT/HelloWorld-1.0-20151013.153708-1.jar, **ReasonPhrase: Forbidden.**
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)

I did lot of research on internet. most people cited proxy issues. but I am on a single machine. the build.local is an entry I made in my hosts file and point to the IP of the VM. So there is no proxy involved here.

like image 525
Knows Not Much Avatar asked Oct 13 '15 15:10

Knows Not Much


People also ask

How do you deploy artifacts to JFrog Artifactory?

Go to the artifact browser, select the repository you want to upload to, and hit the Set Me Up button for instructions. You can upload a file using Artifactory UI. Go to the artifact browser, select the repository you want to upload to, and hit the Upload button for instructions.

How do you deploy artifacts to JFrog Artifactory from Jenkins?

Overview. To install the Jenkins Artifactory Plugin, go to Manage Jenkins > Manage Plugins, click on the Available tab and search for Artifactory. Select the Artifactory plugin and click Download Now and Install After Restart.

How do I transfer files to Artifactory?

To move or copy an artifact or folder, select it in the Tree Browser and then click Move Content or Copy Content from the Actions menu or from the right-click menu. Artifactory will display a list of repositories from which you need to select your Target Repository for the operation.


1 Answers

I was able to solve the issue. My distributionManagement setting above is wrong.

In the JFrog Artifactory go into Artifacts -> libs snapshot local -> Set me up

Here you will see the right setting for distribution management.

enter image description here

like image 175
Knows Not Much Avatar answered Oct 03 '22 03:10

Knows Not Much