使用 Maven、Git:如何标记代码的最新版本?
我正在使用 Maven 3.0.3 和 Git。我使用集成工具 (Bamboo) 将代码分支从 Git 检出到目录中。然后该工具使用 Maven 运行标准构建生命周期(编译、测试、部署)。我想要的是,如果我的 Maven 部署任务成功,我想标记在 Git 中签出的代码版本。我怎样才能从 Maven 做到这一点?我们非常感谢您提供的任何示例配置。
I'm using Maven 3.0.3 with Git. I use an integration tool (Bamboo) to check out a branch of code from Git into a directory. The tool then uses Maven run the standard build lifecycle (compile, test, deploy). What I want is that if my Maven deploy task succeeds, I want to tag the version of my code that is checked out in Git. How can I do this from Maven? Any sample configurations you can provide are greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用 Maven SCM 插件。请参阅高级功能中的标记功能,这应该是相关的。
现在,git 支持并不是现成的,因此您需要依赖 maven-scm-provider-gitexe。另外,为了克服 plexus 异常问题,您还需要添加对更高版本的 plexus 的依赖项。
这对我有用:
Use Maven SCM plugin. See tag functionality in advanced features, which should be relevant.
Now, git support doesn't come out of the box, so you'll need a dependency to maven-scm-provider-gitexe. Also, to overcome plexus exception issue, you'll also need to add a dependency to a later version of plexus.
This is what worked for me:
maven-release-plugin 只需要声明 scm:
生成 git ssh 密钥
https:// help.github.com/articles/generate-ssh-keys/
并运行 mvn release:prepare
更多来自 https://github.com/kevinsawicki/github-maven-example
maven-release-plugin needs only to declare the scm:
generate git ssh keys
https://help.github.com/articles/generating-ssh-keys/
and run mvn release:prepare
more from https://github.com/kevinsawicki/github-maven-example
maven-release-plugin 可以为您执行此操作 - 请参阅此处的示例: http://maven.apache.org/plugins/maven-release-plugin/examples/prepare-release.html
The maven-release-plugin can do this for you -- see an example here: http://maven.apache.org/plugins/maven-release-plugin/examples/prepare-release.html
我推荐我参与的小型开源项目 - 它称为 Quicktag,可与几个 VCS 配合使用 - https://code.google.com/p/quicktag-maven-plugin。添加插件,它将生成带有包含构建信息的静态字段的 Java 类。
I recommend the small open source project I'm part of -it's called Quicktag and works with couple of VCSes - https://code.google.com/p/quicktag-maven-plugin. Add the plugin and it will generate Java class with static fields that contain build information.