I am using Ivy to build my project which has several components. I want to upload these components to Nexus 2.6.4
I am able to publish files to Nexus using curl and the default user name and password:
curl -i -v -u deployment:deployment123 --upload-file a.txt http://myserver:8081/nexus/content/repositories/releases/acp/myproject.app/1.0.0.20160622175545/a.txt
This works perfectly fine! When I go on the Nexus UI to System Feeds: Authorization and Authentication section, I can see a successful connection took place.
When I change the password to a wrong password, I can see a failed connection attempt in the Authorization and Authentication feed.
However, when I build my project using Ant I hit Unauthorized (sounds like 401). and I see absolutely nothing in the Nexus feed (this means no credentials were sent according to the Nexus documentation).
ivysettings.xml:
<ivysettings>
<settings defaultBranch="${ivy.deliver.branch}" defaultResolver="default-chain" />
<properties file="${ivy.settings.dir}/build.properties" />
<credentials host="${repo.host}" realm="${repo.realm}"
username="${repo.user}" passwd="${repo.pass}" />
<resolvers>
<filesystem name="local" transactional="true">
<ivy
pattern="${ivy.default.ivy.user.dir}/local/[organisation]/[module]/[branch]/[revision]/ivy-[revision].xml" />
<artifact
pattern="${ivy.default.ivy.user.dir}/local/[organisation]/[module]/[branch]/[revision]/[type]s/[artifact]-[revision].[ext]" />
</filesystem>
<ibiblio name="nexus" m2compatible="true" root="${nexus-public}" />
<ibiblio name="nexus-releases" m2compatible="true" root="${nexus-releases}" />
<chain name="default-chain">
<resolver ref="local" />
<resolver ref="nexus" />
</chain>
</resolvers>
</ivysettings>
build.properties contains (among other things):
repo.host=myserver
repo.port=8081
repo.user=deployment
repo.pass=deployment123
repo.realm=Nexus Repository Manager
bundle.publish.resolver=nexus-releases
Any ideas?
The realm was incorrect. The right value is Sonatype Nexus Repository Manager. The realm isn't necessary for using curl but it is when authenticating from Ant.
Related
I tried to found a solution to my problem in the publishing post but I couldn't find anything (neither in stackoverflow nor in google)
I'm trying to publishing some artifacts to Nexus using IVY but I'm obtaining credentials error.
In my ivysettings.xml I defined the credentials tag, but it's not working fine (I tried to put the concrete user and pass and doesn't work). If I put the /nexus in the host value as follows:
<ivysettings>
<settings defaultResolver="nexus"/>
<credentials host="${host}/nexus" realm="Nexus Repository Manager"
username="${user}" passwd="${pass}"/>
<property name="nexus-public" value="${nexus.url}/content/groups/public"/>
<property name="nexus-releases" value="${nexus.url}/content/repositories/releases"/>
<property name="nexus-snapshots" value="${nexus.url}/content/repositories/ricrepo/"/>
<property name="nexus-other" value="${nexus.url}/content/repositories/releases/"/>
<resolvers>
<ibiblio name="nexus" m2compatible="true" usepoms="false" root="${nexus-public}"/>
<ibiblio name="nexus-releases" m2compatible="true" root="${nexus-releases}"/>
<ibiblio name="nexus-other" m2compatible="true" root="${nexus-other}"/>
<ibiblio name="nexus-snapshots" m2compatible="true" root="${nexus-snapshots}" checkmodified="true"
changingPattern="*-SNAPSHOT"/>
</resolvers>
</ivysettings>
${host} it's just ${nexus.url} without https:// prefix and without /nexus at the end
And the error is:
[ivy:publish] INFO: Authentication requested but doAuthentication is disabled
Access to URL MYURL was refused by the server
Where MYURL is my complete URL with the repository (so it is resolving well the name...I think)
If I delete de /nexus from the host value (ivysettings would be as follows)
<ivysettings>
<settings defaultResolver="nexus"/>
<credentials host="${host}" realm="Nexus Repository Manager"
username="${user}" passwd="${pass}"/>
<property name="nexus-public" value="${nexus.url}/content/groups/public"/>
<property name="nexus-releases" value="${nexus.url}/content/repositories/releases"/>
<property name="nexus-snapshots" value="${nexus.url}/content/repositories/ricrepo/"/>
<property name="nexus-other" value="${nexus.url}/content/repositories/releases/"/>
<resolvers>
<ibiblio name="nexus" m2compatible="true" usepoms="false" root="${nexus-public}"/>
<ibiblio name="nexus-releases" m2compatible="true" root="${nexus-releases}"/>
<ibiblio name="nexus-other" m2compatible="true" root="${nexus-other}"/>
<ibiblio name="nexus-snapshots" m2compatible="true" root="${nexus-snapshots}" checkmodified="true"
changingPattern="*-SNAPSHOT"/>
</resolvers>
</ivysettings>
The error is:
[ivy:publish] INFO: No credentials available for BASIC 'Sonatype Nexus Repository Manager'
Access to URL MYURL was refused by the server
Please, anyone could help me?
Thanks in advance!
Try setting the realm to "Sonatype Nexus Repository Manager":
<credentials host="${host}" realm="Sonatype Nexus Repository Manager" username="${user}" passwd="${pass}"/>
I've read all the tutorials and examples, and still cannot publish a set of custom jars in my local Ivy repository.
Edit: Basically I want the same behavior as maven-install-plugin.
Here's my setup. I have an Ant task which produces the jars in a given folder. The folder name is not fixed but rather passed as a property in file. I want to get all the jars in this folder and install them in my local Ivy repo so that I can use them on a next step.
Here is my Ant from where I call the ivy:publish:
<project name="Install Ivy Dependencies" xmlns:ivy="antlib:org.apache.ivy.ant" basedir="." default="publish">
<loadproperties srcFile="path_to_folder.properties"/>
<property name="file_pattern" value="${path_to_folder}/[artifact].[ext]" />
<property name="pub_revision" value="1.0.0" />
<target name="resolve">
<ivy:configure file="ivysettings.xml" />
<ivy:resolve file="ivy.xml" />
</target>
<target name="retrieve-all" depends="resolve">
<ivy:retrieve pattern="${file_pattern}" conf="*" />
</target>
<target name="publish" depends="retrieve-all">
<ivy:publish resolver="local" organisation="myOrg" update="true" overwrite="true" pubrevision="${pub_revision}">
<artifacts pattern="${file_pattern}"/>
</ivy:publish>
</target>
</project>
Here's my ivysettings.xml:
<ivysettings>
<resolvers>
<filesystem name="local" local="true"/>
</resolvers>
</ivysettings>
And the ivy.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
<info organisation="myOrg" module="myModule" revision="1.0.0"/>
<publications>
<artifact name="my-custom-jar" ext="jar" type="jar"/>
<artifact name="my-custom-jar-source" ext="jar" type="source"/>
</publications>
</ivy-module>
The error that I am getting when I call the ant task is:
impossible to publish artifacts for myOrg#myModule;1.0.0: java.lang.IllegalStateException: impossible to publish myOrg#myModule;1.0.0!my-custom-jar.jar using local: no artifact pattern defined
I've managed to run my scenario and to resolve my issues using this tutorial There were two major issues in my code/integration.
First one is that you cannot tell Ivy to publish the artifacts in its repository without providing a path to it. I did this with the filesystem resolver:
<filesystem name="local" local="true" transactional="local">
<ivy pattern="${ivy.default.ivy.user.dir}/local/[module]/ivy-[revision].xml" />
<artifact pattern="${ivy.default.ivy.user.dir}/local/[module]/[artifact]-[revision].[ext]" />
</filesystem>
The stupid think about it is this should be build in. If you copy it as is, then everything works. If the config is different, or pointing to a different location - nothing works and you are not told why. I read tons of docs about Apache Ivy and it was nowhere mentioned that these patterns should point to the local Ivy repository. I thought these were the paths from where the jars should be taken. I actually complained about this, but the Ivy documentation is very confusing. Also I think the examples there are wrong. Who would like to publish the artifacts in their ivy.settings.dir. In my case this directory was in my repository!
There was a second issue. It is a smaller one and again very hard to see and fix. There's something wrong the revision param and again the documentation is messed up. If you specify one and the same string for the revision and pub revision the artifacts aren't publish without any explanation why. I fixed it by removing the revision from ivy.xml file.
Last, but not least, I didn't manage to run successfully the "thing" as Ant task, but with java -jar $IVY_JAR ... Maybe the issue was because of the versions, but I was too tired to try it with the fix.
P.S.#cantSleepNow thanks for the help.
You need to add artifact pattern to resolver in ivysettings.xml, something like (example from ivy documentation):
<ivysettings>
<resolvers>
<filesystem name="local" local="true">
<ivy pattern="${ivy.settings.dir}/1/[organisation]/[module]/ivys/ivy-[revision].xml"/>
<artifact pattern="${ivy.settings.dir}/1/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]"/>
</filesystem>
</resolvers>
</ivysettings>
I have an issue where in I have defined dependancies in ivy.xml on our internal corporate svn. I am able to access this svn site without any proxy task in ant. While my dependencies resides on ibiblio, that’s something outside our corporate, and needs proxy inorder to download something. I am facing problem using ivy here.
I have following in build.xml
<target name="proxy">
<property name="proxy.host" value="xyz.proxy.net"/>
<property name="proxy.port" value="8443"/>
<setproxy proxyhost="${proxy.host}" proxyport="${proxy.port}"/>
</target>
<!-- resolve the dependencies of stratus -->
<target name="resolveTestDependency" depends="testResolve, proxy" description="retrieve test dependencies with ivy">
<ivy:settings file="stratus-ivysettings.xml" />
<ivy:retrieve conf="test" pattern="${jars}/[artifact]-[revision].[ext]"/><!--pattern here specifies where do you want to download lib to?-->
</target>
<target name=" testResolve ">
<ivy:settings file="stratus-ivysettings.xml" />
<ivy:resolve conf="test" file="stratus-ivy.xml"/>
</target>
Following is the excerpt from stratus-ivysettings.xml
<resolvers>
<!-- here you define your file in private machine not on the repo (e.g. jPricer.jar or edgApi.jar)-->
<!-- This we will use a url nd not local file system.. -->
<url name="privateFS">
<ivy pattern="http://xyz.svn.com/ivyRepository/ [organisation]/ivy/ivy.xml"/>
</url>
.
.
.
<url name="public" m2compatible="true">
<artifact pattern="http://www.ibiblio.org/maven2/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"/>
</url>
.
.
.
So as can be seen here for getting ivy.xml, I don’t need any proxy as its within our own network which cant be accesses when I set proxy. But on the other hand I am using ibiblio as well which is external to our network and works only with proxy. So above build.xml wont work in that case. Can somebody help here.
I don’t need proxy while getting ivy.xml (as if I have proxy, ivy wont be able to find ivy file behind proxy from within the network), and I just need it when my resolver goes to public url.
When using setproxy, use the nonproxyhosts attribute to specify the hosts that the proxy should not be used for (pipe separated). e.g, modify the setproxy task in your example to
<setproxy proxyhost="${proxy.host}"
proxyport="${proxy.port}"
nonproxyhosts="xyz.svn.com"/>
For more details see http://ant.apache.org/manual/Tasks/setproxy.html
I have some project's that integrates ivy, i publish my artifact in two possible repositories, local, that respond to a folder, and beta, that respond to a server where archiva is installed and where i share my jars with my colleague.
Now the problem: i need to find a way to build a resolution chains that do this things:
search between the various repository the latest.integration.
retrieve that jar.
if that jar is already in my cache do not have to download it.
if the artifact in the cache has the same version of the artifact in one of the repository take the latest in chronology's order.
now i have try everything that's the setting
Ivy setting
<chain name="resolvechain">
<ibiblio name="b1" root="archivaURLforbeta" m2compatible="true" checkmodified="true" latest="latest-time"/>
<filesystem name="b2" checkmodified="true" >
<artifact pattern="${ivy.local.default.root}/${ivy.local.default.artifact.pattern}" />
</filesystem>
<ibiblio name="b3" root="archivaURLforrelease" m2compatible="true" latest="latest-time"/>
<ibiblio name="b4" m2compatible="true"/>
</chain>
that's the target of resolve in the Build.xml file:
<ivy:settings file="${archiva.set}" />
<ivy:resolve refresh="true" resolveMode="dynamic" changing="true"/>
<ivy:retrieve sync="true" overwritemode="newer" pattern="./lib/[artifact]-[type]-[revision](.[ext])" />
and that's an example on how the dependency are written in ivy.xml file
<dependency org="organization" name="module-name" rev="latest.integration" transitive="false" conf="default" />
the questions are two:
First of all is there any error according to my needs?
Second, what i'm trying to do, is possible?
i asked these two questions because it seems to me that setting checkmodified true and changing true let my application skip entirely my cache, and my projects continuing to download the artifacts every time.
I have found the solution searching between different questions here in stackoverflow and in some issues solution in the ivy comunity with my colleagues.
The FileSystem need it's own latest-time strategy, every resolve take note of their own modules last date revision.
Here the mod in the code:
<filesystem name="b2" checkmodified="true" latest="latest-time">
<artifact pattern="${ivy.local.default.root}/${ivy.local.default.artifact.pattern}" />
</filesystem>
I have an issue where in I have defined dependancies in ivy.xml on our internal corporate svn. I am able to access this svn site without any proxy task in ant. While my dependencies resides on ibiblio, that’s something outside our corporate, and needs proxy inorder to download something. I am facing problem using ivy here.
I have following in build.xml
<target name="proxy">
<property name="proxy.host" value="xyz.proxy.net"/>
<property name="proxy.port" value="8443"/>
<setproxy proxyhost="${proxy.host}" proxyport="${proxy.port}"/>
</target>
<!-- resolve the dependencies of stratus -->
<target name="resolveTestDependency" depends="testResolve, proxy" description="retrieve test dependencies with ivy">
<ivy:settings file="stratus-ivysettings.xml" />
<ivy:retrieve conf="test" pattern="${jars}/[artifact]-[revision].[ext]"/><!--pattern here specifies where do you want to download lib to?-->
</target>
<target name=" testResolve ">
<ivy:settings file="stratus-ivysettings.xml" />
<ivy:resolve conf="test" file="stratus-ivy.xml"/>
</target>
Following is the excerpt from stratus-ivysettings.xml
<resolvers>
<!-- here you define your file in private machine not on the repo (e.g. jPricer.jar or edgApi.jar)-->
<!-- This we will use a url nd not local file system.. -->
<url name="privateFS">
<ivy pattern="http://xyz.svn.com/ivyRepository/ [organisation]/ivy/ivy.xml"/>
</url>
.
.
.
<url name="public" m2compatible="true">
<artifact pattern="http://www.ibiblio.org/maven2/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"/>
</url>
.
.
.
So as can be seen here for getting ivy.xml, I don’t need any proxy as its within our own network which cant be accesses when I set proxy. But on the other hand I am using ibiblio as well which is external to our network and works only with proxy. So above build.xml wont work in that case. Can somebody help here.
I don’t need proxy while getting ivy.xml (as if I have proxy, ivy wont be able to find ivy file behind proxy from within the network), and I just need it when my resolver goes to public url.
When using setproxy, use the nonproxyhosts attribute to specify the hosts that the proxy should not be used for (pipe separated). e.g, modify the setproxy task in your example to
<setproxy proxyhost="${proxy.host}"
proxyport="${proxy.port}"
nonproxyhosts="xyz.svn.com"/>
For more details see http://ant.apache.org/manual/Tasks/setproxy.html