使用Maven,Git:如何标记我的代码的最新版本?

Dav*_*ave 12 git tagging maven

我正在使用Maven 3.0.3和Git.我使用集成工具(Bamboo)将Git中的代码分支签出到目录中.然后该工具使用Maven运行标准构建生命周期(编译,测试,部署).我想要的是,如果我的Maven部署任务成功,我想标记我在Git中检出的代码版本.我怎么能从Maven那里做到这一点?您可以提供的任何样本配置都非常感谢.

eis*_*eis 6

使用maven scm插件.请参阅高级功能中的标记功能,这些功能应该相关.

现在,git支持不是开箱即用的,所以你需要依赖maven-scm-provider-gitexe.此外,为了克服丛异常问题,您还需要为更高版本的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>
Run Code Online (Sandbox Code Playgroud)