简体   繁体   English

如何在settings.xml中使用artifactory-maven-plugin中的用户名和密码?

[英]How use username and password in artifactory-maven-plugin from settings.xml?

Here is a configuration sample of artifactory-maven-plugin : artifactory-maven-plugin的配置示例:

<build>
    <plugins>
        ...
        <plugin>
            <groupId>org.jfrog.buildinfo</groupId>
            <artifactId>artifactory-maven-plugin</artifactId>
            <version>2.6.1</version>
            <inherited>false</inherited>
            <executions>
                <execution>
                    <id>build-info</id>
                    <goals>
                        <goal>publish</goal>
                    </goals>
                    <configuration>
                        <deployProperties>
                            <gradle>awesome</gradle>
                            <review.team>qa</review.team>
                        </deployProperties>
                        <publisher>
                            <contextUrl>https://oss.jfrog.org</contextUrl>
                            <username>deployer</username>
                            <password>{DESede}...</password>
                            <repoKey>libs-release-local</repoKey>
                            <snapshotRepoKey>libs-snapshot-local</snapshotRepoKey>
                        </publisher>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

In that case I have to manual setup contextUrl , userName and password . 在这种情况下,我必须手动设置contextUrluserNamepassword While standart maven deploy plugin uses such parameters from setting.xml (like that): 虽然标准maven部署插件使用来自setting.xml这样的参数(像那样):

<servers>
  <server>
    <username>username</username>
    <id>server-id</id>
    <password>pass</password>
  </server>
</servers>

Why jfrom did not use username, url, ... etc. from setting.xml ? 为什么jfrom没有使用来自setting.xml username,url,...等? Is there a way to specify only server id without pass and username? 有没有办法只指定没有pass和username的服务器ID?

Of course someone can define a properties in settings xml and use them in plugin definition, but in that case these properties can be easily shared with all projects and be outputted by anyone to console during third party builds. 当然有人可以在设置xml中定义属性并在插件定义中使用它们,但在这种情况下,这些属性可以很容易地与所有项目共享,并在第三方构建期间由任何人输出到控制台。

<properties>
   <username></username>
</properties>

The official documentation actually suggests a different approach: 官方文档实际上提出了一种不同的方法:

Keeping your Artifactory publisher credentials secure 保证您的Artifactory发布者凭据安全
If you prefer to keep your Artifactory publisher credentials ( username and password ) secure (rather than providing them as free text in the plugin configuration), we recommend storing them as environment variables or system properties and have the plugin read them when needed. 如果您希望保持Artifactory发布者凭据( usernamepassword )安全(而不是在插件配置中将它们作为自由文本提供),我们建议将它们存储为环境变量或系统属性,并在需要时让插件读取它们。 Since the usual Maven deploy does not support environment variables or system properties in settings.xml , this capability is unique to the Maven Artifactory Plugin. 由于通常的Maven部署不支持settings.xml环境变量或系统属性,因此此功能对于Maven Artifactory插件是唯一的。

Hence, indeed the expected functionality of referring to a server id defined in the settings.xml is not implemented . 因此,实际上未实现引用settings.xml定义的服务器标识的预期功能。


One side note : to enforce good practices, deployments to a Maven Repository should be executed in automated way by a Continuous Integration server (ie Jenkins). 一方面注意 :为了实施良好实践,应该由持续集成服务器(即Jenkins)以自动方式执行Maven资源库的部署。 In this case, the Artifactory plugin for the CI server (ie the Artifactory Jenkins Plugin ) would handle it in a safe way, centralizing this mechanism only in one place (the CI server), behind user management and governance, avoiding accidental actions from local machine. 在这种情况下,CI服务器的Artifactory插件(即Artifactory Jenkins插件 )将以安全的方式处理它,仅在一个地方(CI服务器)集中此机制,在用户管理和治理之后,避免来自本地的意外操作机。 Things that could go wrong otherwise (publishing from local machine): 否则可能出错的事情(从本地机器发布):

  • code may not be aligned under version control, publishing a harder to troubleshoot artifact 代码可能无法在版本控制下对齐,发布更难以解决工件问题
  • tests may have been skipped, publishing a potential bug 测试可能已被跳过,发布了潜在的错误
  • build may be only reproducible on that machine, publishing a non re-buildable artifact 构建可能只能在该计算机上重现,发布不可重构的工件

Having it in the pom.xml may indeed expose it somehow to the issues above (somebody from the team could mistakenly trigger it), while automated processes and gates would insure certain steps. 将它放在pom.xml可能确实以某种方式暴露于上述问题(团队中的某些人可能错误地触发它),而自动化流程和门将确保某些步骤。

I agree that setting up an automated build box and using jenkins/hudson or some similar product would be ideal for this. 我同意建立一个自动构建盒并使用jenkins / hudson或类似产品将是理想的选择。 If you are strapped for time and still want something that has a little bit more security to it, you could consider setting up ssh authentication. 如果你时间紧张,仍然想要一些更安全的东西,你可以考虑设置ssh身份验证。 documentation below: 文档如下:

https://www.jfrog.com/confluence/display/RTF/SSH+Integration https://www.jfrog.com/confluence/display/RTF/SSH+Integration

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM