我为“nightly”或“latest”版本找到的解决方案如下:
-
将部署设置为
on tags: true
-
当建立一个
提交(TRAVIS_TAG not set),将最新标记移动到当前提交
git tag -f
用手推它
git push --tags -f
,但不要设置TRAVIS\u标签;这将阻止部署当前构建(因为
标记上:真
)
-
标记应触发新的
已标记
注意,为了能够从Travis构建中推送,您需要传递一个身份验证令牌。例如,这在许多地方都有描述
there
.
同步之所以有效,是因为每个作业都执行相同的标记操作。第一个推送的实际上是移动Github repo上的“最新”标签,下一个推送的则是“所有内容都是最新的”。您只需要对所有作业使用相同的标记。
下面是我的脚本:
#!/usr/bin/env bash
set -ev
# If we don't have a tag, use the Maven project version to set/update a tag and push.
# Don't set TRAVIS_TAG so that this build will not be deployed.
# The new build that will be triggered by the push will be tagged and deployed as usual.
if [ -z "$TRAVIS_TAG" ] ; then
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
git config --local user.name "Olivier"
git config --local user.email "ogerardin@yahoo.com"
git tag -f "$VERSION"
git push --tags -f https://${GH_TOKEN}@github.com/ogerardin/xpman.git
fi
注意,我没有使用固定的标记,但是我提取了Maven项目版本,但是您可以对版本使用任何东西,只要对所有作业(平台)都是相同的。
before_deploy
,因为
部署前
这意味着它不会被调用为未标记的构建。我用
after_success