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.
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:
<project>
<scm>
<connection>scm:git:https://[email protected]/my-project.git</connection>
<developerConnection>scm:git:https://[email protected]/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>