在 Jenkins 构建后脚本中访问 Maven 构建属性以检索已部署的工件

发布于 2025-01-05 07:15:25 字数 225 浏览 2 评论 0 原文

我有一个 Jenkins 构建并部署到远程存储库的 Maven 项目。然后我需要将部署的 .war 复制到外部位置。我一直在尝试使用构建后 shell 脚本来执行此操作,但我没有看到任何从 Maven 获取构建信息的方法(例如,已部署工件的 URL)。有没有一种方法可以得到它,或者有一种方法可以更集成到 Maven 中?我可以使用 Jenkins 构建参数来计算部署路径,但这看起来像是一个 hack。

谢谢, 史蒂夫

I've got a Maven project that Jenkins builds and deploys to a remote repository. I then need to copy the deployed .war to an external location. I've been trying to do this with a post-build shell script but I don't see any way to get the build information from maven (for example, the URL of the deployed artifact). Is there a way to get it, or a way to do this that's more integrated into maven? I can calculate the deployment path using Jenkins build parameters but it seems like a hack.

Thanks,
Steve

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

╰ゝ天使的微笑 2025-01-12 07:15:25

在 Maven 构建之后,您应该始终在以下位置找到构建工件:

target/<artifactId>-<version>.<packaging>

您可以使用 maven pom.xml 中访问此路径.html#Properties" rel="nofollow noreferrer">属性(参见 pom 参考 >)

${project.build.directory}/${project.artifactId}-${project.version}.${project.packaging}

至构建后将工件复制到另一个位置,您可以使用此线程中描述的多种方法。

After a maven build you should always find the build artifact at

target/<artifactId>-<version>.<packaging>

You can access this path within the maven pom.xml by using the maven properties (see pom reference)

${project.build.directory}/${project.artifactId}-${project.version}.${project.packaging}

To copy the artifact to another location after the build you can use several approaches described e.g. in this thread.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文