Travis CI将构建推送到新的存储库

时间:2016-01-18 21:06:18

标签: git github travis-ci

我试图在after_success期间将travis CI项目的构建版本推送到不同的存储库

构建完成后,travis将运行以下脚本:

git config user.name "Travis CI"
git config user.email "fake@fake.com"
git config --global push.default simple
git add . -f #force adding to include files in .gitignore
git commit -m "built with love by travis <3"
git remote add production https://${GH_TOKEN}:x-oauth-basic@github.com/my_username/repo.git
git push production master --force #ensure repo is in correct state

GH_TOKEN是存储在.travis.yml中的加密github令牌。显然,我已经编辑了一些私人信息。

当travis运行此脚本时,我收到以下错误:

remote: fatal: did not receive expected object [redacted]
error: unpack failed: index-pack abnormal exit
To https://[redacted token]:x-oauth-basic@github.com/my_username/repo.git
 ! [remote rejected] HEAD -> master (failed)
error: failed to push some refs to 'https://[redacted token]:x-oauth-basic@github.com/my_username/repo.git'

这是我的脚本,travis还是github的问题?

1 个答案:

答案 0 :(得分:0)

我不确定问题是什么,但我修改了我的脚本以在travis中初始化一个新的空git存储库,一切顺利进行:

rm -rf .git/
git init
git config user.name "Travis CI"
git config user.email "travis@domain.com"
git config --global push.default simple
git add .
git commit -m "built with love by travis <3"
git remote add production https://${GH_TOKEN}@github.com/user/repo.git
git push production master --force