使用Ivy-Ant在nexus中发布工件:凭证未授权?

时间:2015-07-23 09:20:47

标签: java ant publish ivy nexus

这是我的代码 ivy.xml文件

    <?xml version="1.0" encoding="UTF-8"?>
    <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="nameOrganisation" module="nameModule" revision="1.0"   status="release" publication="20150723102057">
        </info>
    <publications>
        <artifact name="artifactName" type="jar" ext="jar"/>
    </publications>
        <dependencies>
            <dependency org="org.springframework" name="spring-web-servlet" rev="3.0.5.RELEASE" transitive="false"/>
...

build.xml文件

<target name="publish" description="Upload to Nexus">
        <ivy:settings id="ivy.settings" file="${ivy.settings}">
        <credentials host="host" realm="Sonatype Nexus Repository Manager" username="${repo.username}" passwd="${repo.password}"/>
        </ivy:settings>
        <ivy:retrieve />
         <ivy:makepom ivyfile="${ivy.file}" pomfile="ivy.pom"/>
        <ivy:publish resolver="publish" overwrite="true" publishivy="false" srcivypattern="${ivy.file}" settingsRef="ivy.settings" forcedeliver="true" organisation="organisation" module="nameModule" pubrevision="1.0" revision="1.0">
            <artifacts pattern="${lib.app.dir}/[artifact](-[classifier]).[ext]"/>
        </ivy:publish>

    </target>

ivysettings-public.xml

<ivysettings>
  <settings defaultResolver="nexus"/>
 <!-- <credentials host="host" realm="Sonatype Nexus Repository Manager" username="user" passwd="pwd"/>-->
  <resolvers>
   <chain name="nexus">
    <ibiblio name="name1" m2compatible="true" root="http://host:8080/nexus/content/repositories/name1/"/>
    <ibiblio name="central" m2compatible="true" root="http://host:8080/nexus/content/repositories/name2/"/>

  </chain>
  </resolvers>
</ivysettings>

当我运行build.xml时,我总是一样,是否忽略了我的凭据?还是另一个问题?

 buildPublish.xml:39: impossible to publish artifacts for     organisation#nameModule;1.0: java.io.IOException: Access to URL     [http://host:8080/nexus/content/repositories/name1/organisation/nameModule/1.0/n    ameModule-1.0.jar] was refused by the server: Unauthorized

我需要一些想法! 感谢

1 个答案:

答案 0 :(得分:3)

有同样的问题。 4个小时后,我找到了解决方案。

我必须在我的凭据中分隔主机和端口:

<credentials 
 host="${repo.host}"
 port="${repo.port}" 
 realm="${repo.realm}" 
 username="${repo.username}" 
 passwd="${repo.password}"/>