一次github和jenkins集成构建异常处理

来源:互联网 发布:微信连接不了网络 编辑:程序博客网 时间:2024/06/08 12:39

最近Jenkins出问题了,github总是behind Apache eagle 6个commits。下面是我们构建的shell

#!/bin/bashunset SSH_ASKPASSgit checkout mastergit statusecho "Git remote..."git remote add upstream https://github.com/apache/eagle.gitgit remote set-url origin "https://{username}:{token}@github.com/1haodian/eagle.git"echo "Fetch..."git fetch upstreamecho "Rebase..."git rebase upstream/master echo "Pushing with force ..."git push --force origin master > /dev/null 2>&1 || exit 1echo "Pushed deployment successfully"exit 0

检查token没问题,构建也不报错。只能去jenkins主机去查问题,在workspace下 git log,得知rebase执行成功,apache eagle最新的代码也在,只能说明最后一步push出问题了。直接执行push也不报错,但是很快执行结束。没辙。。。

git branch时发现,checkout依旧如此。

[chitin eaglemaster]$ git branch* (no branch)[chitin eaglemaster]$ git checkout masterPrevious HEAD position was 1f16c58... Fix compile error introduced by EAGLE-993HEAD is now at 26a2889... Fix compile error introduced by EAGLE-993[chitin eaglemaster]$ git branch [chitin eaglemaster]$ git checkout -b masterSwitched to a new branch 'master'[chitin eaglemaster]$ git branch       `这里写代码片`              * master* (no branch)

上网查询发现需要执行git checkout -b master,果然可以,遂再次push

git push  origin mastererror: src refspec master matches more than one.error: failed to push some refs to 'https://{username}:{token}@github.com/1haodian/eagle.git'

再次请教白谷老师,大致意思是origin有“master”的branch和“master”的tag,注意这儿branch和tag同名,删除orgin上的“master” tag

[yhd@yhd-hk eaglemaster]$ git push origin --delete tag master
To https://{username}:{token}@github.com/1haodian/eagle.git
- [deleted] master

再次push成功

This branch is 66 commits ahead of apache:master.

记录下,防止下次遇到忘记。

原创粉丝点击