我目前正在为多个项目设置 CI/CD 链。我想在我们的 Jenkins 服务器的每个构建中注入(inject)一个 maven 插件(这个:https://github.com/cedricwalter/git-branch-renamer-maven-plugin)。有没有一种方法可以将插件注入(inject)到构建中,而无需将其添加到每个项目的每个 pom.xml 中?
最佳答案
您可以使用 mavenSettings.xml 使用 profile
部分来做到这一点:https://maven.apache.org/settings.html
然后将 mavenSettings.xml 设置为 Jenkins 使用的 Maven 安装。
...
<profiles>
<profile>
<id>AllwaysOn</id>
<activation>
<activeByDefault>true</activeByDefault>
...
</activation>
<!-- add plugin config here -->
</profile>
</profiles>
...
然后您可以在那里添加您的特定插件配置。
关于Maven 注入(inject)插件 settings.xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53483562/