在哪里保存setting-security.xml文件以使用Maven加密?

San*_*pal 9 nexus maven teamcity-9.1

我们使用的是TeamCity 9.1和默认的捆绑Maven版本3.0.5

在构建中,我们使用Maven与Nexus服务器进行交互.

我们想加密Maven settings.xml文件中的密码,如本文所述:http: //maven.apache.org/guides/mini/guide-encryption.html

这需要一个settings-security.xml文件,该文件应与Maven settings.xml文件位于同一文件夹中.setting.xml文件保存在TeamCity中,并作为自定义"用户设置选择"文件部署到服务器 - 因此我不知道它在代理上的部署位置.

我们应该在哪里保存settings-security.xml文件?是否应该手动部署到所有代理?如果是这样,应该在哪个文件夹中?(我们有Windows和Linux代理)

我不确定在TeamCity中使用加密的Maven密码的最佳做法是什么,所以我会提供任何帮助.

谢谢

One*_*erd 5

"I don't know where it is being deploy to on the agent" .. You can find this within the build log output .. Just search for settings.. With User settings file, they are typically stored in a temp directory in the build agent.

When you attempt to encrypt your password using (as per the encryption guide):

mvn --encrypt-password my_password
Run Code Online (Sandbox Code Playgroud)

It expects to find: settings-security.xml; if this isn't present you will get.

[ERROR] Error executing Maven.
[ERROR] java.io.FileNotFoundException: /home/krbuild/.m2/settings-security.xml (No such file or directory)
[ERROR] Caused by: /home/krbuild/.m2/settings-security.xml (No such file or directory)
Run Code Online (Sandbox Code Playgroud)

So the security file needs to be stored on each agent on which you intend to run your build configuration (not in VCS). There is still no dedicated support for this feature; see TW-39595

The work around would be to set an agent property, e.g.

path.to.maven.security=/path/to/file/security-settings.xml
Run Code Online (Sandbox Code Playgroud)

Then refer to it in your Maven build step:

-Dsettings.security=%path.to.maven.security%
Run Code Online (Sandbox Code Playgroud)

  • 这有助于我们将 settings.xml 和 settings-security.xml 文件存储到不同的位置 - `mvn -s /path/to/settings.xml -Dsettings.security=/path/to/settings-security.xml干净部署`。 (2认同)