我想在发布期间使用物理用户的凭据。我使用下面的堆栈:我自己的maven插件包装maven-release-plugin,jenkins,nexus,git。在Jenkins上,我使用参数和密码掩码插件为正在执行构建的用户提供用户名和密码。问题是Jenkins,Git和Nexus的证书可能不同,所以我不能重复使用它们。很明显,我可以使用CI用户来验证所有内容,但由于某些规定,我无法做到这一点。在使用maven发布插件时传递nexus的凭证
首先我尝试使用-Dusername和-Dpassword,但1)这只适用于git,2)git和nexus的密码不同。除此之外,我想为git使用基于密钥的身份验证。
然后我试图执行行家离型插件之前,通过改变会话/项目的对象以编程方式更改凭证:
final MavenExecutionRequest request = new DefaultMavenExecutionRequest()
.setLocalRepository(session.getLocalRepository())
.setPluginArtifactRepositories(session.getCurrentProject().getPluginArtifactRepositories())
.setRemoteRepositories(session.getCurrentProject().getRemoteArtifactRepositories())
.setBaseDirectory(new File(properties.getCheckoutDirectory()))
.setPluginGroups(session.getPluginGroups())
.setProjectPresent(true)
.setPom(new File(properties.getCheckoutDirectory() + "/pom.xml"))
.setGoals(Arrays.asList(goal))
.setInteractiveMode(false)
.setUserSettingsFile(new File(session.getSystemProperties().getProperty("user.home") + "/.m2/settings.xml"))
;
request.setUserProperties(preparePropertiesForMvn(properties));
for (ArtifactRepository artifactRepository : session.getCurrentProject().getRemoteArtifactRepositories()) {
if (artifactRepository.getId().equals("nexus-releases")) {
artifactRepository.setAuthentication(new Authentication(properties.getNexusUser(),properties.getNexusPassword()));
}
}
final MavenExecutionResult result = defaultMaven.execute(request);
在非常终末期行家 - 部署 - 插件(这是由释放的插件执行)读取〜/ .m2/settings.xml文件并从中获取(错误-CI)凭证。
是否有另一种方式比准备自己的定制settings.xml文件的构建与建立凭据?我想避免将凭据存储在本地存储上。
我试着用这个,但我不知道为什么maven-deploy-plugin无论如何读取settings.xml而不是使用这个设置。 – user2810516
该版本是从您从命令行执行的主版本中单独构建而成的。你看过“准备目标”吗? –