Here是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>
在这种情况下,我必须手动设置contextUrl,userName和密码.虽然标准maven部署插件使用来自setting.xml的这样的参数(像那样):
<servers>
<server>
<username>username</username>
<id>server-id</id>
<password>pass</password>
</server>
</servers>
为什么jfrom没有使用来自setting.xml的username,url,…等?有没有办法只指定没有pass和username的服务器ID?
当然有人可以在设置xml中定义属性并在插件定义中使用它们,但在这种情况下,这些属性可以很容易地与所有项目共享,并在第三方构建期间由任何人输出到控制台.
<properties>
<username></username>
</properties>
解决方法:
official documentation实际上提出了一种不同的方法:
Keeping your Artifactory publisher credentials secure
If you prefer to keep your Artifactory publisher credentials (username
andpassword
) 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. Since the usual Maven deploy does not support environment variables or system properties insettings.xml
, this capability is unique to the Maven Artifactory Plugin.
因此,实际上未实现引用settings.xml中定义的服务器标识的预期功能.
一方面注意:为了实施良好实践,应该由Continuous Integration服务器(即Jenkins)以自动方式执行Maven存储库的部署.在这种情况下,CI服务器的Artifactory插件(即Artifactory Jenkins Plugin)将以安全的方式处理它,仅在一个地方(CI服务器)集中此机制,在用户管理和治理之后,避免来自本地机器的意外操作.否则可能出错的事情(从本地机器发布):
>代码可能无法在版本控制下对齐,发布更难以解决工件问题
>可能已跳过测试,发布潜在错误
> build可能只能在该计算机上重现,发布不可重构的工件
将它放在pom.xml中可能确实以某种方式暴露于上述问题(团队中的某些人可能错误地触发它),而自动化流程和门将确保某些步骤.