首页 > 解决方案 > 如果 Jenkins 已经知道,为什么要在 POM 中添加分发管理

问题描述

和标题说的差不多。

我正在尝试为 WSO2 构建 CI/CD。在遵循本教程时: https ://docs.wso2.com/display/IntegrationCloud/Implement+Continuous+Integration+and+Deployment+with+Jenkins

它没有说明在 POM 上添加 DistributionManagement,它甚至还有一个特殊的 POM 配置部分,但是,jenkins 正在抛出一个

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project HelloWorld: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1]

因此,如果 jenkins 已经有了 repo URL、分支和 github,并且 POM 有一个部署目标,应该部署到一个 URL:

1) 为什么我需要分销管理?

2) 我可以将它指向我的文件系统之类的任何位置,还是必须将其指向我实际想要部署到的云?

标签: mavenjenkinscontinuous-integrationwso2continuous-deployment

解决方案


根据maven文档,您可以使用标签distributionManagement将构建工件直接上传到带有maven的服务器

https://maven.apache.org/pom.html

重要的部分是 url 标签。您可以使用 scp 或 sftp(可能是其他协议)

scp://user:password@serverUrl/var/some/directory

我建议在本地测试命令 deploy ,当你确定它有效时,使用 jenkins。


如果你想做最先进的 jenkins 工作,我建议使用 jenkins 管道,使用 sh 命令执行 maven 并使用 ssh-steps-plugin 提供的 ssh 步骤发布到服务器


推荐阅读