Artifactory Maven 示例失败并显示 401 错误代码
Artifactory Maven example fails with 401 error code
我正在本地主机上试用 Artifactory。尽管我关注了他们 tutorial
做他们的
Maven example,我失败了,返回 401 状态码。这是我得到的错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project multi: Failed to deploy artifacts: Could not transfer artifact org.jfrog.test:multi:pom:3.7-20190117.083916-1 from/to snapshots (http://localhost:8081/artifactory/libs-snapshot-local): Failed to transfer file http://localhost:8081/artifactory/libs-snapshot-local/org/jfrog/test/multi/3.7-SNAPSHOT/multi-3.7-20190117.083916-1.pom with status code 401 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project multi: Failed to deploy artifacts: Could not transfer artifact org.jfrog.test:multi:pom:3.7-20190117.083916-1 from/to snapshots (http://localhost:8081/artifactory/libs-snapshot-local): Failed to transfer file http://localhost:8081/artifactory/libs-snapshot-local/org/jfrog/test/multi/3.7-SNAPSHOT/multi-3.7-20190117.083916-1.pom with status code 401
这是 settings.xml 的内容,位于 /Users/my_user_name/.m2:
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<servers>
<server>
<username>${security.getCurrentUsername()}</username>
<password>${security.getEscapedEncryptedPassword()!"AP84FzVbdvwcgreF8m9HT77ESkA"}</password>
<id>central</id>
</server>
<server>
<username>${security.getCurrentUsername()}</username>
<password>${security.getEscapedEncryptedPassword()!"AP84FzVbdvwcgreF8m9HT77ESkA"}</password>
<id>snapshots</id>
</server>
</servers>
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://localhost:8081/artifactory/libs-release</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://localhost:8081/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://localhost:8081/artifactory/libs-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://localhost:8081/artifactory/libs-snapshot</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
我已将此添加到 pom.xml
<distributionManagement>
<snapshotRepository>
<id>snapshots</id>
<name>0e5e20a55438-snapshots</name>
<url>http://localhost:8081/artifactory/libs-snapshot-local</url>
</snapshotRepository>
</distributionManagement>
错误代码 401 提示我存在身份验证问题。我想知道 settings.xml 如何解析凭据,例如${security.getCurrentUsername()}
?我什至在 settings.xml 中输入了纯用户名和密码,但仍然失败。
你能告诉我我的设置有什么问题吗?我该如何解决这个问题?
注意:工件 6.5.x 中存在 a bug,已在版本 6.5.2 中解决,这会阻止正确处理已过滤的资源。
${security.getCurrentUsername()}
是 filtered resource 的一种用法,它在人工制品中允许将文本文件视为通过 FreeMarker 模板过滤。
当您在工件 UI 中下载 settings.xml
文件时,${security.[]}
字段将被替换为您当前登录的用户名和加密密码(如果 该错误不存在)。由于错误,或者 if 你 copy/paste 文本内容而不是下载, settings.xml 将包含那些文字未替换的字符串,maven 不会替换它们,因为它们不存在于 Maven 构建上下文中。
如您 link 编辑的视频所示,您需要单击 download snippet
link,而不是复制文本;否则,您可以 copy/paste 文本,然后您需要在其中输入您的人工用户名和密码。
对于那些登陆这里并在尝试使用 artefactory cloud 时得到 401 的人,对我来说,问题是我添加了 public 镜像部分(这不是由 Generate Maven Settings
link:
这给了我 settings.xml 中的一个部分:
<mirrors>
<mirror>
<mirrorOf>*</mirrorOf>
<name>public</name>
<url>https://{my-domain}.jfrog.io/artifactory/public</url>
<id>public</id>
</mirror>
</mirrors
因为我正在使用这个镜像,所以我需要在服务器部分添加进一步的身份验证:
<server>
<username>{username}</username>
<password>{encrypted password}</password>
<id>public</id>
</server
我正在本地主机上试用 Artifactory。尽管我关注了他们 tutorial 做他们的 Maven example,我失败了,返回 401 状态码。这是我得到的错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project multi: Failed to deploy artifacts: Could not transfer artifact org.jfrog.test:multi:pom:3.7-20190117.083916-1 from/to snapshots (http://localhost:8081/artifactory/libs-snapshot-local): Failed to transfer file http://localhost:8081/artifactory/libs-snapshot-local/org/jfrog/test/multi/3.7-SNAPSHOT/multi-3.7-20190117.083916-1.pom with status code 401 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project multi: Failed to deploy artifacts: Could not transfer artifact org.jfrog.test:multi:pom:3.7-20190117.083916-1 from/to snapshots (http://localhost:8081/artifactory/libs-snapshot-local): Failed to transfer file http://localhost:8081/artifactory/libs-snapshot-local/org/jfrog/test/multi/3.7-SNAPSHOT/multi-3.7-20190117.083916-1.pom with status code 401
这是 settings.xml 的内容,位于 /Users/my_user_name/.m2:
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<servers>
<server>
<username>${security.getCurrentUsername()}</username>
<password>${security.getEscapedEncryptedPassword()!"AP84FzVbdvwcgreF8m9HT77ESkA"}</password>
<id>central</id>
</server>
<server>
<username>${security.getCurrentUsername()}</username>
<password>${security.getEscapedEncryptedPassword()!"AP84FzVbdvwcgreF8m9HT77ESkA"}</password>
<id>snapshots</id>
</server>
</servers>
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://localhost:8081/artifactory/libs-release</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://localhost:8081/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://localhost:8081/artifactory/libs-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://localhost:8081/artifactory/libs-snapshot</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
我已将此添加到 pom.xml
<distributionManagement>
<snapshotRepository>
<id>snapshots</id>
<name>0e5e20a55438-snapshots</name>
<url>http://localhost:8081/artifactory/libs-snapshot-local</url>
</snapshotRepository>
</distributionManagement>
错误代码 401 提示我存在身份验证问题。我想知道 settings.xml 如何解析凭据,例如${security.getCurrentUsername()}
?我什至在 settings.xml 中输入了纯用户名和密码,但仍然失败。
你能告诉我我的设置有什么问题吗?我该如何解决这个问题?
注意:工件 6.5.x 中存在 a bug,已在版本 6.5.2 中解决,这会阻止正确处理已过滤的资源。
${security.getCurrentUsername()}
是 filtered resource 的一种用法,它在人工制品中允许将文本文件视为通过 FreeMarker 模板过滤。
当您在工件 UI 中下载 settings.xml
文件时,${security.[]}
字段将被替换为您当前登录的用户名和加密密码(如果 该错误不存在)。由于错误,或者 if 你 copy/paste 文本内容而不是下载, settings.xml 将包含那些文字未替换的字符串,maven 不会替换它们,因为它们不存在于 Maven 构建上下文中。
如您 link 编辑的视频所示,您需要单击 download snippet
link,而不是复制文本;否则,您可以 copy/paste 文本,然后您需要在其中输入您的人工用户名和密码。
对于那些登陆这里并在尝试使用 artefactory cloud 时得到 401 的人,对我来说,问题是我添加了 public 镜像部分(这不是由 Generate Maven Settings
link:
这给了我 settings.xml 中的一个部分:
<mirrors>
<mirror>
<mirrorOf>*</mirrorOf>
<name>public</name>
<url>https://{my-domain}.jfrog.io/artifactory/public</url>
<id>public</id>
</mirror>
</mirrors
因为我正在使用这个镜像,所以我需要在服务器部分添加进一步的身份验证:
<server>
<username>{username}</username>
<password>{encrypted password}</password>
<id>public</id>
</server