Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Maven 2 Maven+;Mercurial用于构建数字_Maven 2_Mercurial_Build Process_Hudson_Build Numbers - Fatal编程技术网

Maven 2 Maven+;Mercurial用于构建数字

Maven 2 Maven+;Mercurial用于构建数字,maven-2,mercurial,build-process,hudson,build-numbers,Maven 2,Mercurial,Build Process,Hudson,Build Numbers,我不知道如何在我的Maven构建中使用Mercurial修订id(理想情况下,我希望它出现在我的JAR和war清单中) 我能找到的最接近的解决方案是: mvn -DbuildNumber=`hg id -i` 这在Windows或我的Hudson服务器上都不起作用。 幸运的是,Hudson标记了我的构建,但如果构建也标记了Mercurial changset id,我希望得到更多的保证。请查看并查看已接受答案中的链接。基本上,您希望做同样的事情,只是希望使用Mercurial的目标来获得内容为

我不知道如何在我的Maven构建中使用Mercurial修订id(理想情况下,我希望它出现在我的JAR和war清单中)

我能找到的最接近的解决方案是:

mvn -DbuildNumber=`hg id -i`
这在Windows或我的Hudson服务器上都不起作用。
幸运的是,Hudson标记了我的构建,但如果构建也标记了Mercurial changset id,我希望得到更多的保证。

请查看并查看已接受答案中的链接。基本上,您希望做同样的事情,只是希望使用Mercurial的目标来获得内容为
hg id-i
changeset
属性。不幸的是,
hg id-i
太长,无法使用。我创建了一个脚本,它将计算一个准确的构建编号。然而,有两个例外。如果分支上没有以前的版本,则该版本无效。如果本地回购协议发生变化,则该协议无效。在我的构建脚本中,每当发生这种情况时,我都将构建标记为“x.x.UNSTABLE”

我使用REL_模式拾取当前分支中标记为实际版本的最后一个标记。然后,我通过跟踪该版本的提交日志计数+自该版本以来对分支的所有提交来计算构建编号

#!/bin/bash
REL_PATTERN="release-[0-9]*\.[0-9]*\.[0-9]*"
BRANCH=$( hg branch )
CURR_REV=$( hg id -n )
if [  "${CURR_REV: -1}" = "+" ] ; then
  echo "ERROR: This workspace contains uncommitted code. Cannot calculate build number" >&2
  echo "UNSTABLE"
  exit 1
fi
RELEASE=$( hg log --rev="branch($BRANCH) and tag() and 1:$CURR_REV" -T "{tags} {rev}\n"|grep "${REL_PATTERN} "|tail -1 )
if [ "$RELEASE" = "" ] ; then
  echo "ERROR: Unable to locate version tag" >&2
  echo "UNSTABLE"
  exit 1
fi
RELEASE_REV=$( echo $RELEASE|cut -f 2 -d ' ' )
RELEASE_TAG=$( echo $RELEASE|cut -f 1 -d ' ' )
REVS=$( hg log -P $RELEASE_REV -b $BRANCH -T "{rev}\n"|wc -l )
BUILD=$( hg log -r1:$CURR_REV -P $RELEASE_REV -b $BRANCH -T "{rev}\n"|wc -l )
echo "BRANCH=$BRANCH" >&2
echo "CURR_REV=$CURR_REV" >&2
echo "RELEASE_REV=$RELEASE_REV" >&2
echo "RELEASE_TAG=$RELEASE_TAG" >&2
echo "BUILD=$BUILD" >&2
echo $BUILD