Maven 上传 zip 和 pom 到 Artifactory 失败

问题描述 投票:0回答:1

我在 Artifactory 中有 Maven 存储库。 我想使用maven部署命令上传pom文件和zip文件(来自源代码的包)。我不想使用curl(顺便说一句,它可以工作)来做到这一点,但我试图在maven中实现同样的事情。

我有一个settings.xml

<settings>
    <interactiveMode>false</interactiveMode>
    <profiles/>
    <servers>
    <server>
    <id>maven-snapshot-local</id>
    <username>svcjenkins</username>
    <password>***</password>  
    </server>
   </server></servers>
</settings>

我有pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>fa</groupId>
    <artifactId>FIXCommon</artifactId>
    <version>LATEST-SNAPSHOT</version>
    <packaging>pom</packaging>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <groupId>fa</groupId>
                    <artifactId>FIXCommon</artifactId>
                    <version>LATEST-SNAPSHOT</version>
                    <packaging>zip</packaging>
                    <file>fix-common.zip</file>
                    <url>https://artifactory.domain.dev/artifactory/maven-snapshot-local</url>
                </configuration>
              </plugin>
        </plugins>
    </build>
</project>`

我运行命令:

mvn -U -X clean install deploy:deploy-file

错误是:

Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to retrieve remote metadata fa:FIXCommon:LATEST-SNAPSHOT/maven-metadata.xml: Could not transfer metadata fa:FIXCommon:LATEST-SNAPSHOT/maven-metadata.xml from/to remote-repository (https://artifactory.domain.dev/artifactory/maven-snapshot-local): authentication failed for https://artifactory.domain.dev/artifactory/maven-snapshot-local/fa/FIXCommon/LATEST-SNAPSHOT/maven-metadata.xml, status: 401 Unauthorized`

当我尝试用curl做同样的事情时,它通过了:

curl -u user:pass fix-common.zip https://artifactory.domain.dev/artifactory/maven-snapshot-  local/fa/FIXCommon/LATEST-SNAPSHOT/fix-common.zip

您能看一下我的 XML 定义并告诉我是否遗漏了什么吗?

java maven pom.xml maven-deploy-plugin
1个回答
0
投票

解决方案是在 pom 定义中也包含 repositoryId 字段。

<distributionManagement>
    <repository>
        <id>maven-snapshot-local</id>
        <url>https://artifactory.domain.dev/artifactory/maven-snapshot-local</url>
    </repository>
</distributionManagement>
<build>
    <plugins>
        <plugin>
            ............
            <configuration>
                <repositoryId>maven-snapshot-local</repositoryId>
© www.soinside.com 2019 - 2024. All rights reserved.