一次github和jenkins集成構建異常處理

最近Jenkins出問題了,github總是behind Apache eagle 6個commits。下面是我們構建的shell

#!/bin/bash
unset SSH_ASKPASS
git checkout master
git status
echo "Git remote..."
git remote add upstream https://github.com/apache/eagle.git
git remote set-url origin "https://{username}:{token}@github.com/1haodian/eagle.git"
echo "Fetch..."
git fetch upstream
echo "Rebase..."
git rebase upstream/master 
echo "Pushing with force ..."
git push --force origin master > /dev/null 2>&1 || exit 1
echo "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 master
Previous HEAD position was 1f16c58... Fix compile error introduced by EAGLE-993
HEAD is now at 26a2889... Fix compile error introduced by EAGLE-993
[chitin eaglemaster]$ git branch 

[chitin eaglemaster]$ git checkout -b master
Switched to a new branch 'master'
[chitin eaglemaster]$ git branch       `這裏寫代碼片`              
* master
* (no branch)

上網查詢發現需要執行git checkout -b master,果然可以,遂再次push

git push  origin master
error: 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.

記錄下,防止下次遇到忘記。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章