ant-ivy-user mailing list archives

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

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

The "java.io.IOException [...] 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
Manager".
-> 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:
http://ant.apache.org/ivy/history/latest-milestone/resolver/ibiblio.html
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
root:
C:\Dev\UtilityClasses\.\ivy-1.1-SNAPSHOT.xml

Voila! I hope this helps for future reference!

Cheers,

 - Georges



-----Original Message-----
From: Georges Labrèche [mailto:glabreche@stream57.com] 
Sent: Wednesday, June 10, 2009 5:54 PM
To: ivy-user@ant.apache.org
Subject: RE: Publishing An Artifact to Archiva From The Command Line Interface (CLI)

Hello,

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:
http://ant.apache.org/ivy/history/latest-milestone/resolver/ibiblio.html

This is what my URL resolver looks like:

<url name="url-archiva-internal">
 <ivy pattern="http://rep.company.com/archiva/repository/internal/[module]/[revision]/ivy-[revision].xml"
/>
 <artifact pattern="http://rep.company.com/archiva/repository/internal/[module]/[revision]/[artifact]-[revision].[ext]"
/>
 <artifact pattern="http://rep.company.com/archiva/repository/internal/[module]/[revision]/[artifact].[ext]"
/>
</url>


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

Exception in thread "main" java.io.IOException: Access to URL http:/
/rep.company.com/archiva/repository/internal/Artifact.Core/1.1.1/Artifact.Core-1.1.1.jar 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" java.io.IOException: Access to URL http://rep.company.com/archiva/re
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(AbstractURLHandler.java:73)
     [exec]  at org.apache.ivy.util.url.BasicURLHandler.upload(BasicURLHandler.java:206)
     [exec]  at org.apache.ivy.util.url.URLHandlerDispatcher.upload(URLHandlerDispatcher.java:82)
     [exec]  at org.apache.ivy.util.FileUtil.copy(FileUtil.java:140)
     [exec]  at org.apache.ivy.plugins.repository.url.URLRepository.put(URLRepository.java:84)
     [exec]  at org.apache.ivy.plugins.repository.AbstractRepository.put(AbstractRepository.java:130)
     [exec]  at org.apache.ivy.plugins.resolver.RepositoryResolver.put(RepositoryResolver.java:226)
     [exec]  at org.apache.ivy.plugins.resolver.RepositoryResolver.publish(RepositoryResolver.java:209)
     [exec]  at org.apache.ivy.core.publish.PublishEngine.publish(PublishEngine.java:282)
     [exec]  at org.apache.ivy.core.publish.PublishEngine.publish(PublishEngine.java:261)
     [exec]  at org.apache.ivy.core.publish.PublishEngine.publish(PublishEngine.java:170)
     [exec]  at org.apache.ivy.Ivy.publish(Ivy.java:600)
     [exec]  at org.apache.ivy.Main.run(Main.java:284)
     [exec]  at org.apache.ivy.Main.main(Main.java:168)



Thanks and Regards,

 - Georges

-----Original Message-----
From: Georges Labrèche [mailto:glabreche@stream57.com] 
Sent: Tuesday, June 09, 2009 7:57 PM
To: ivy-user@ant.apache.org
Subject: Publishing An Artifact to Archiva From The Command Line Interface (CLI)

Hello,

 

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 />
task.

 

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
1.1.1

 

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


Mime
View raw message