【发布时间】:2013-06-14 13:33:47
【问题描述】:
在jenkins shell中,我想添加远程仓库,但是如果仓库名称存在,那么我遇到了
fatal: remote I-WANT-TO-PUSH already exists.
詹金斯意外中止。
下面我要伪代码。
if [ ! git remote I-WANT-TO-PUSH exist? ]
git remote add I-WANT-TO-PUSH http://i-want-to-push.example.com
fi
git push I-WANT-TO-PUSH
如何做到这一点?
已编辑:(感谢@Nikolay)
下面是几乎实际的代码:
o=$(git remote | grep 'pushable')
if [[ $o == '' ]]; then
hub remote add pushable https://$GH_TOKEN@github.com/foo/bar.git
fi
然后我得到了:
++ grep pushable
++ git remote
+ o=
Build step 'Execute shell' marked build as failure
【问题讨论】: