使用Maven,Git:如何标记代码的最新版本?
我在Git中使用Maven 3.0.3。我使用集成工具(bambol)将代码的一个分支从Git签出到一个目录中。然后,该工具使用Maven运行标准构建生命周期(编译、测试、部署)。我想要的是,如果Maven部署任务成功,我想标记在Git中签出的代码版本。我怎样才能从Maven那里做到这一点?非常感谢您提供的任何示例配置。请使用。看,这应该是相关的 现在,git支持不是现成的,所以您需要一个依赖项来支持它。此外,为了克服这个问题,您还需要向plexus的更高版本添加依赖项 这就是我的工作原理:使用Maven,Git:如何标记代码的最新版本?,git,maven,tagging,Git,Maven,Tagging,我在Git中使用Maven 3.0.3。我使用集成工具(bambol)将代码的一个分支从Git签出到一个目录中。然后,该工具使用Maven运行标准构建生命周期(编译、测试、部署)。我想要的是,如果Maven部署任务成功,我想标记在Git中签出的代码版本。我怎样才能从Maven那里做到这一点?非常感谢您提供的任何示例配置。请使用。看,这应该是相关的 现在,git支持不是现成的,所以您需要一个依赖项来支持它。此外,为了克服这个问题,您还需要向plexus的更高版本添加依赖项 这就是我的工作原理: &
<project>
<scm>
<connection>scm:git:https://username@github.com/my-project.git</connection>
<developerConnection>scm:git:https://username@github.com/my-project.git</developerConnection>
</scm>
<!-- snip -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-gitexe</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
<version>1.0</version>
<configuration>
<tag>test</tag>
<connectionType>connection</connectionType>
</configuration>
<executions>
<execution>
<id>tag</id>
<phase>deploy</phase>
<goals>
<goal>tag</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<!-- snip -->
</project>
scm:git:https://username@github.com/my-project.git
scm:git:https://username@github.com/my-project.git
org.apache.maven.plugins
maven scm插件
org.codehaus.plexus
尾丛
2.1
org.apache.maven.scm
maven scm提供程序gitexe
1.2
1
测试
连接
标签
部署
标签
maven release插件可以为您做到这一点——请看这里的一个示例:我推荐我所参与的小型开源项目,它被称为Quicktag,可与几台VCSE一起使用。添加插件,它将生成包含构建信息的静态字段的Java类 maven发布插件只需声明scm:
<scm>
<url>https://github.com/username/repoName</url>
<connection>scm:git:git://github.com/username/repoName.git</connection>
<developerConnection>scm:git:git@github.com:username/repoName.git</developerConnection>
<tag>HEAD</tag>
</scm>
https://github.com/username/repoName
scm:git:git://github.com/username/repoName.git
scm:git:git@github.com:username/repoName.git
头
生成git ssh密钥
并运行mvn发布:准备
更多信息来自COol,这正是我想要的,尽管当我背靠背运行它时,在第二次运行时会出现“[ERROR]fatal:tag'qa_release'ready exists”错误。我可能不得不将此作为另一个问题来回答。是的,标记名需要一些动态(属性),在本例中它是静态的。如果可以将最新的标记作为命令行参数提供,则可以使用${parameter.version}并使用-Dparameter.version=v1.2运行maven,然后使用它。如果需要maven插件自动生成,则需要一些额外的逻辑。
${project.version}
作为标记名是合理的。这并不能解决OP的用例