How to set tag for Maven release

I'm using the Maven Release Plugin and I'm trying to tag every release with my Jenkins build number.

I've tried this from pom.xml :

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-release-plugin</artifactId>
        <version>2.5.3</version>
        <configuration>
          <tagNameFormat>${env.BUILD_NUMBER}</tagNameFormat>
        </configuration>
      </plugin>

And also from Jenkins when I'm calling Maven:

mvn release:prepare -tag=${env.BUILD_NUMBER}

However, I'm getting:

Unable to tag SCM
[ERROR] Provider message:
[ERROR] The git-tag command failed.
[ERROR] Command output:
[ERROR] fatal: tag 'my-project-1.3' already exists

I'm not sure what 1.3 stands for.

So how can I tag the release? I am doing any mistake?


Your pom is probably on version 1.3-SNAPSHOT

mvn release:prepare

Will update the version to 1.3, create the git tag "artifactid-version" in your case my-project-1.3, then set the version in your pom to 1.4-SNAPSHOT for the next iteration.

To fix your problem delete the tag see How to delete a git remote tag? then run mvn release:prepare again.

You may need to set your version back to 1.3-SNAPSHOT, this can be done with

mvn versions:set -DnewVersion=1.3-SNAPSHOT

Or just edit you pom/poms.

链接地址: http://www.djcxy.com/p/49292.html

上一篇: 不能编辑/删除Git标签

下一篇: 如何为Maven发行版设置标签