authentication - Maven 服务器身份验证作为配置文件属性

标签 authentication maven-2 settings profiles

我正在尝试在构建服务器上设置共享身份验证系统。 我们有几个 Maven 项目,它们声明了如何针对我们拥有的不同团队进行部署(每个团队都有自己的身份验证用户/密码):

<profile>
  <id>release-profile</id>
  <distributionManagement>
    <repository>
        <id>rep-releases</id>
        <name>rep-releases</name>
        <url>http://somewhere-releases</url>
    </repository>
    <snapshotRepository>
        <id>rep-snapshots</id>
        <name>rep-snapshots</name>
        <url>http://somewhere-snapshots</url>
    </snapshotRepository>
  </distributionManagement>
</profile>    

然后我在 settings.xml 中声明对声明的服务器的身份验证,如下所示:

<servers>
  <server>
    <id>rep-releases</id>
    <username>${release.user.name}</username>
    <password>${release.user.password}</password>
  </server>     
  <server>
    <id>rep-snapshots</id>
    <username>${release.user.name}</username>
    <password>${release.user.password}</password>
  </server>      
</servers>

最后,根据我要部署的项目,我在构建服务器的 settings.xml 中定义了多个配置文件:

<profile>
  <id>dep-team1</id>
  <activation>
    <activeByDefault>false</activeByDefault>
  </activation>
  <properties>
    <release.user.name>team1-user</release.user.name>
    <release.user.password>team1-password</release.user.password>
  </properties>
</profile>

问题是,在部署项目时,我收到了如下身份验证错误 (HTTP 401):

Error deploying artifact: Failed to transfer file: http://......./my-project-0.2-20090423.123247-3.pom. Return code is: 401

如果我通过将属性替换为团队的用户/密码来修改服务器身份验证,则一切正常。

标签 不接受值作为属性吗?

其他人如何设置他们的构建系统以实现相同的目标?

感谢您的帮助。

编辑:我正在使用 hudson,对我来说,一个解决方案是安装多次 maven2 并为每个团队提供重复的设置(用户/密码除外),并将每个项目与良好的 maven 安装联系起来。我必须承认这个解决方案并没有让我着迷......

最佳答案

如果您有多个团队,因此有多个身份验证方案,最简单、最直接的方法就是在 distributionManagement 中使用不同的 id。因此,您可以使用 team1-repo/team2-repo 来代替rep-releases/rep-snapshots(在发布和快照之间分离身份验证通常没有任何值(value)......特别是如果您使用具有良好安全控制的repo manager)

然后在构建机器的设置中,只需为构建服务器的每个团队定义用户和密码即可。

这种方法确实有一个缺点,如果您在单个公司 pom 中定义存储库,它会扰乱继承...但如果您有团队级别的 pom,那就很容易了。

另一个想法是为什么同一台构建机器在构建时需要以不同的人身份登录?该构建机器不应该具有大部分完全访问权限吗?

关于authentication - Maven 服务器身份验证作为配置文件属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/781527/

相关文章:

java - GMail OAuth 身份验证。我是否正确检索 OAuth token ?

java - Maven中的依赖jar文件列表

maven-2 - 我如何找出 Apache Buildr/Maven 2 存储库名称

directory - 如何更改 Sublime Text 3 中的当前工作目录?

authentication - 环回 4 : Extend the built in User model

flash - 潘多拉网站用户资料系统

maven-2 - 使用Maven进行项目分发

phpstorm - 如何在 PhpStorm 中设置编辑器背景颜色

django 2无法将环境变量从.env文件加载到setting.py文件

Firebase,使用REST服务自动登录