使用Travis-CI,是否有可能在不推送新提交到GitHub的情况下触发重建?
用例:由于外部性而导致构建失败。这个来源实际上是正确的。如果简单地重新运行,它将构建OK并通过。
例如,由于包服务器宕机,apt-get失败,但服务器再次备份。然而,构建状态“卡”在“失败”,直到推送新的提交。
有什么方法来推动Travis-CI做另一个构建,而不是推动一个“虚拟”提交?
使用Travis-CI,是否有可能在不推送新提交到GitHub的情况下触发重建?
用例:由于外部性而导致构建失败。这个来源实际上是正确的。如果简单地重新运行,它将构建OK并通过。
例如,由于包服务器宕机,apt-get失败,但服务器再次备份。然而,构建状态“卡”在“失败”,直到推送新的提交。
有什么方法来推动Travis-CI做另一个构建,而不是推动一个“虚拟”提交?
当前回答
你可以使用Travis CLI来实现。如文档所述,首先安装CLI工具,然后:
travis login --org --auto
travis token
您可以将这个令牌保存在环境变量TRAVIS_TOKEN中,只要保存它的文件没有在公共的某个地方受到版本控制。
我使用这个函数来提交触发器:
function travis_trigger() {
local org=$1 && shift
local repo=$1 && shift
local branch=${1:-master} && shift
body="{
\"request\": {
\"branch\": \"${branch}\"
}
}"
curl -s -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Travis-API-Version: 3" \
-H "Authorization: token $TRAVIS_TOKEN" \
-d "$body" \
"https://api.travis-ci.org/repo/${org}%2F${repo}/requests"
}
其他回答
你可以使用Travis CLI来实现。如文档所述,首先安装CLI工具,然后:
travis login --org --auto
travis token
您可以将这个令牌保存在环境变量TRAVIS_TOKEN中,只要保存它的文件没有在公共的某个地方受到版本控制。
我使用这个函数来提交触发器:
function travis_trigger() {
local org=$1 && shift
local repo=$1 && shift
local branch=${1:-master} && shift
body="{
\"request\": {
\"branch\": \"${branch}\"
}
}"
curl -s -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Travis-API-Version: 3" \
-H "Authorization: token $TRAVIS_TOKEN" \
-d "$body" \
"https://api.travis-ci.org/repo/${org}%2F${repo}/requests"
}
我发现了另一种强制重新运行CI构建和其他触发器的方法:
运行git commit——modify——no-edit,不做任何修改。这将重新创建当前分支中的最后一次提交。 Git push——force-with-lease origin pr-branch。
如果您没有写权限,只需关闭并重新打开PR。
有时,服务器确实犯了一些错误。 尝试登出/登录,然后一切都可能是正确的。 (是的,今天下午就发生在我身上。)
If you have write access to the repo: On the build's detail screen, there is a button ↻ Restart Build. Also under "More Options" there is a trigger build menu item. Note: Browser extensions like Ghostery may prevent the restart button from being displayed. Try disabling the extension or white-listing Travis CI. Note2: If .travis.yml configuration has changed in the upstream, clicking rebuild button will run travis with old configuration. To apply upstream changes for travis configuration one has to add commit to PR or to close / reopen it. If you've sent a pull request: You can close the PR then open it again. This will trigger a new build.
重新构建:
触发构建: