ant-ivy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Georges Labrèche <>
Subject RE: Publishing An Artifact to Archiva From The Command Line Interface (CLI)
Date Thu, 11 Jun 2009 03:14:26 GMT

For archiving purposes, here's the solution to my problem:

The " [...] was refused by the server: Unauthorized" exception is thrown
because, when ivy tries to put the artifact in the Archiva repository, a "HTTP Status-Code
403: Forbidden" is returned.

Now, without logging into Archiva, I have access to the repository file system via a web browser.
This means that there is no restrictive web container permission configuration (I am using
Apache) which would return the 403 status code. Hence the problem is in the configuration
of Archiva itself and not that of Ivy nor the web container.

When Ivy tries to publish an artifact to Archiva, it does so as an Archiva "guest" user. This
guest user is a default Archiva user. By default, these are the effective roles assigned to
the guest user:

# Guest
# Repository Observer - snapshots
# Repository Observer - internal

The following roles need to be added to the guest user via Archiva's Edit Roles page for the
guest user:

# Repository Manager - snapshots
# Repository Manager - internal

Accessing Archiva's Edit Roles page is rather indirect and non-intuitive:
-> Login to Archiva as admin
-> Click on "User Roles" on the navigation menu
-> Click on "Guest"
-> Click on "Guest (guest - )" in the Permissions section (under "Users defined with the
current role")
-> Click on "Edit Roles" in the "Effective Roles" section
-> Under "Resources Roles", check the repository you wish to publish to under "Repository
-> Click on Submit!

And that takes care of the "Unauthorized" exception when you try to publish to Archiva.
Keep in mind that it's ok for me to do this because my Archiva is only accessible through
an internal organizational network that is not intended to be reachable directly from the
public Internet (http://archiva.mycompany.local). So in this case there is no security concern
in outside unauthenticated guests having write permissions to the artifact repositories.

Furthermore, despite what the documentation says regarding the ibiblio resolver not being
able to handle publishing:
I have successfully published using such a resolver. Maybe the documentation needs to be updated?

One question that remains unanswered is why is the following file being created in the project's

Voila! I hope this helps for future reference!


 - Georges

-----Original Message-----
From: Georges Labrèche [] 
Sent: Wednesday, June 10, 2009 5:54 PM
Subject: RE: Publishing An Artifact to Archiva From The Command Line Interface (CLI)


The Command Line I am now using is the following:

-jar tools\ivy\ivy.jar 
-ivy path/ivy.xml  
-settings path/ivysettings.xml 
-publishpattern C:\Dev\UtilityClasses/build/Artifact.Core.dll 
-revision 1.1.1 
-publish url-archiva-internal 
-overwrite true

I added a URL resolver to my ivysettings.xml because I was using ibiblio and, apparently,
that does not handle publishing:

This is what my URL resolver looks like:

<url name="url-archiva-internal">
 <ivy pattern="[module]/[revision]/ivy-[revision].xml"
 <artifact pattern="[module]/[revision]/[artifact]-[revision].[ext]"
 <artifact pattern="[module]/[revision]/[artifact].[ext]"

When executing ivy with the above command line, I now get an authentication error:

Exception in thread "main" Access to URL http:/
/ was
refused by the server: Unauthorized

So, at least I am able to attempt to access the proper URL to publish my artifact. My questions
now are the following:
 - How does authentication work when publishing artifacts and what exactly needs to be done?
Should I be using the http auth options and if so, with which credentials? How are they set?
 - The error message displays "Artifact.Core.jar" as my artifact name ([artifact]-[revision].[ext]).
But the extension shouldn't be "jar", it should be "dll". How do I set this?

For reference, here's the full exception stack trace:

[exec] Exception in thread "main" Access to URL
pository/internal/Artifact.Core/1.1.1/Artifact.Core-1.1.1.jar was refused by the server: Unauthorized
     [exec]  at org.apache.ivy.util.url.AbstractURLHandler.validatePutStatusCode(
     [exec]  at org.apache.ivy.util.url.BasicURLHandler.upload(
     [exec]  at org.apache.ivy.util.url.URLHandlerDispatcher.upload(
     [exec]  at org.apache.ivy.util.FileUtil.copy(
     [exec]  at org.apache.ivy.plugins.repository.url.URLRepository.put(
     [exec]  at org.apache.ivy.plugins.repository.AbstractRepository.put(
     [exec]  at org.apache.ivy.plugins.resolver.RepositoryResolver.put(
     [exec]  at org.apache.ivy.plugins.resolver.RepositoryResolver.publish(
     [exec]  at org.apache.ivy.core.publish.PublishEngine.publish(
     [exec]  at org.apache.ivy.core.publish.PublishEngine.publish(
     [exec]  at org.apache.ivy.core.publish.PublishEngine.publish(
     [exec]  at org.apache.ivy.Ivy.publish(
     [exec]  at
     [exec]  at org.apache.ivy.Main.main(

Thanks and Regards,

 - Georges

-----Original Message-----
From: Georges Labrèche [] 
Sent: Tuesday, June 09, 2009 7:57 PM
Subject: Publishing An Artifact to Archiva From The Command Line Interface (CLI)



I am trying to upload an artifact to an Archiva repository via the CLI.


The reason I am using the CLI is because I am working on a .NET projects hence using NAnt
build scripts. Using NAnt means that I do not have access to the convenient Ant ivy tasks
such as <ivy:publish /> and must rely on executing the ivy.jar via NAnt's <exec />


Every sample I have stumbled upon publishes artifacts via the <ivy:publish /> task.
I need to achieve the same thing but via the CLI.


Looking and the -help output of ivy.jar I notice the following publishing options:

==== publish options

 -publish <resolvername>      use given resolver to publish to

 -publishpattern <artpattern> use given pattern to find artifacts to publish

 -revision <revision>         use given revision to publish the module

 -status <status>             use given status to publish the module

 -overwrite                   overwrite files in the repository if they exist



I have started experimenting with the following command line:


-jar tools\ivy\ivy.jar -publishpattern C:\Dev\UtilityClasses/build/Artifact.dll -revision


This throws an error saying that the ivy file is not found. I'm not sure why it needs the
ivy file when publishing an artifact. Can someone shed some light into this?

Adding the -ivy option and pointing to the project's ivy file results in a success but not
upload occurred. It only created a ivy-1.1.1.xml file ( a copy of ivy.xml) in my project's
root folder.


Also, when I manually upload an artifact to Archiva I need to input the following information:
Group Id, Artifact Id, Version And Packaging (dll, in my case). I also tell Archiva to generate
a Maven 2 POM file. How would I set all of these values via an ivy CLI publish? Other than
revision for the version number, I don't seem to see options I can set which would relate
to the information Archiva would expect upon an upload.


Thanks and regards,


-          Georges

View raw message