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}"/>
Related
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.
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>
For a legacy project I'm currently introducing Ivy with Artifactory. I have some reusable scripts that work pretty well for jars and zips with sources. However, now I need to publish several large artifacts - zip-files, largest ~150MB. The publish fails with the following error-message:
impossible to publish artifacts for com.siemens.nucleus.tmbo#TMBO-RELEASE;1.6-SNAPSHOT: java.io.IOException: Error writing to server
Caused by: java.io.IOException: Error writing to server at sun.net.www.protocol.http.HttpURLConnection.writeRequests(HttpURLConnection.java:578)
A workaround is to change the order of artifacts: small one first. It seems it has something to do with authentication - ivy seems to try with anonymous first, if that fails it tries with the configured user, but in the error case it only tries with anonymous, but twice (interpretation of Artifactory's access-log).
I'd rather go with a solution than a workaround - any ideas? Can I force ivy to always use the credentials?
Here is my 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.6-SNAPSHOT"
status="integration" />
<configurations>
<include file="${ivy.confs.file}" />
</configurations>
<publications>
<artifact name="large_artifact" ext="zip" type="deploy" />
<artifact name="small_artifact" ext="zip" type="deploy" />
</publications>
<dependencies>
<!-- None. -->
</dependencies>
</ivy-module>
EDIT:
ivysettings.xml:
<ivy-settings>
<settings defaultResolver="default" />
<include url="ivysettings-shared.xml" />
<include url="${ivy.default.settings.dir}/ivysettings-local.xml" />
<resolvers>
<chain name="default" returnFirst="true" checkmodified="true">
<resolver ref="local" />
<resolver ref="shared" />
</chain>
</resolvers>
</ivy-settings>
ivysettings-shared.xml:
<ivy-settings>
<!--Authentication required for publishing (deployment). 'Artifactory Realm'
is the realm used by Artifactory so don't change it. -->
<credentials host="my-url.com" realm="Artifactory Realm"
username="${ivy.repo.my-company.username}" passwd="${ivy.repo.my-company.password}" />
<resolvers>
<chain name="shared">
<url name="my-releases" m2compatible="false">
<artifact
pattern="https://my-url.com/artifactory/my-releases/[organisation]/[module]/[revision]/[type]s/[artifact](-[classifier])-[revision].[ext]" />
<ivy
pattern="https://my-url.com/artifactory/my-releases/[organisation]/[module]/[revision]/[type]s/ivy-[revision].xml" />
</url>
<url name="my-snapshots" m2compatible="false">
<artifact
pattern="https://my-url.com/artifactory/my-snapshots/[organisation]/[module]/[revision]/[type]s/[artifact](-[classifier])-[revision].[ext]" />
<ivy
pattern="https://my-url.com/artifactory/my-snapshots/[organisation]/[module]/[revision]/[type]s/ivy-[revision].xml" />
</url>
<ibiblio name="my-external" m2compatible="true"
root="https://my-url.com/artifactory/all" />
</chain>
</resolvers>
</ivy-settings>
ivy.repo.my-company.username and ivy.repo.my-company.password are defined in a properties file %IVY-HOME%\security.properties
I am trying to create custom resolver in my ivysettings.xml file:
<ivysettings>
<settings defaultResolver="default"/>
<resolvers>
<chain name="default">
<url name="scala-tools">
<ivy pattern="http://scala-tools.org/repo-releases/[organisation]/[module]/[revision]/ivy-[revision].xml" />
<artifact pattern="http://scala-tools.org/repo-releases/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"/>
<artifact pattern="http://scala-tools.org/repo-releases/[organisation]/[module]/[revision]/[artifact].[ext]"/>
</url>
<!--<ibiblio name="ibiblio"/>-->
</chain>
</resolvers>
</ivysettings>
As you can see, I have just one UrlResolver that will try to find my dependencies in scala-tools repo. If I specify my dependencies correctly than ivy will try to find it in http://scala-tools.org/repo-releases/org.scala-lang/scala-library/2.8.0/scala-library-2.8.0.jar and http://scala-tools.org/repo-releases/org.scala-lang/scala-library/2.8.0/scala-library.jar (yep, according to my instructions in ivysettings.xml) Obviously, it doesn't find anything. To get thing working I must specify dependencies in this way:
<ivy-module version="2.2">
<info organisation="org.yoba" module="Yoba"/>
<dependencies>
<dependency org="org/scala-lang" name="scala-library" rev="2.8.0"/>
<!--<dependency org="org.scala-lang" name="scala-library" rev="2.8.0"/>-->
<dependency org="org/scala-lang" name="scala-compiler" rev="2.8.0"/>
<!--<dependency org="org.scala-lang" name="scala-compiler" rev="2.8.0"/>-->
</dependencies>
</ivy-module>
Q:How to change artifact pattern / something else to force ivy to make it's job right way?
1: http://scala-tools.org/repo-releases/ scala-tools repo
ivy.xml
I checked the POM for scala-compiler and discovered that it references the module scala-library. This means only need one dependency declaration is required in the ivy file:
<ivy-module version="2.0">
<info organisation="org.yoba" module="Yoba"/>
<dependencies>
<dependency org="org.scala-lang" name="scala-compiler" rev="2.8.0" conf="default"/>
</dependencies>
</ivy-module>
The version number needs to be "2.0"
Included the default mapping to avoid downloading the optional dependencies
ivysettings.xml
I recommend using the ibiblio resolver when downloading from any Maven compliant repository.
<ivysettings>
<settings defaultResolver="scalatools"/>
<resolvers>
<ibiblio name="scalatools" root="http://scala-tools.org/repo-releases" m2compatible="true"/>
</resolvers>
</ivysettings>
If you need to download other libraries the settings file can be enhanced, so that ivy only retrieves the scala modules from the scala repository
<ivysettings>
<settings defaultResolver="central"/>
<resolvers>
<ibiblio name="central" m2compatible="true"/>
<ibiblio name="scalatools" root="http://scala-tools.org/repo-releases" m2compatible="true"/>
</resolvers>
<modules>
<module organisation="org.scala-lang" resolver="scalatools"/>
</modules>
</ivysettings>
I have been playing with the basic Ivy Tutorial and have gradually extended to a state where I now have a seprate ivy.xml defining my dependancies and with the ivy jar inside the apache ant installation.
I have also managed to define a shared repository to stop ivy popping off to an external repository. This has been done by defining properties in the resolve task.
<target name="resolve" depends="" description="Resolve the dependencies">
<property name="ivy.shared.default.root" value="C:/ivy/localLibsStore" />
<property name="ivy.shared.default.artifact.pattern" value="[module]/[revision]/[type]s/[artifact]-[revision].[ext]" />
<ivy:retrieve/>
</target>
However I have tried moving these properties into a separate ivysettings.xml file with no luck.
So the question is what should I have in my ivysettings.xml ?
My latest attempt below gives the error:
unknown resolver null
no resolver found for ...
<ivysettings>
<property name="ivy.shared.default.root" value="C:/ivy/localLibsStore" />
<property name="ivy.shared.default.artifact.pattern" value="[module]/[revision]/[type]s/[artifact]-[revision].[ext]" />
<resolvers>
<filesystem name="shared">
<ivy pattern="${ivy.shared.default.root}/${ivy.shared.default.ivy.pattern}" />
<artifact pattern="${ivy.shared.default.root}/${ivy.shared.default.artifact.pattern}" />
</filesystem>
</resolvers>
</ivysettings>
sussed it.
Found this good description of ivy
I have changed my settings.xml to look like this
<ivysettings>
<settings defaultResolver="chained"/>
<property name="java.net.maven.pattern" value="[organisation]/jars/[module]-[revision].[ext]"/>
<property name="ivy.shared.default.root" value="C:/ivy/localLibsStore" />
<property name="ivy.shared.default.artifact.pattern" value="[module]/[revision]/[type]s/[artifact]-[revision].[ext]" />
<resolvers>
<filesystem name="sharedbill">
<ivy pattern="${ivy.shared.default.root}/${ivy.shared.default.ivy.pattern}" />
<artifact pattern="${ivy.shared.default.root}/${ivy.shared.default.artifact.pattern}" />
</filesystem>
<chain name="chained" returnFirst="true">
<resolver ref="sharedbill"/>
<ibiblio name="ibiblio" m2compatible="true"/>
<ibiblio name="java-net-maven1" root="http://download.java.net/maven/1" pattern="${java.net.maven.pattern}" m2compatible="false"/>
<ibiblio name="java-net-maven2" root="http://download.java.net/maven/2/" m2compatible="true"/>
<url name="sourceforge">
<artifact pattern="http://easynews.dl.sourceforge.net/sourceforge/[organization]/[module]_[revision].zip" />
<artifact pattern="http://easynews.dl.sourceforge.net/sourceforge/[organization]/[module]-[revision].zip" />
</url>
</chain>
</resolvers>
</ivysettings>