Git 詹金斯-Faiure测试

Git 詹金斯-Faiure测试,git,bash,shell,jenkins,Git,Bash,Shell,Jenkins,在我的Jenkins测试(仅shell)中,我想检查命令的存在状态(在本例中,是git remote的存在): 但是,如果remote不存在,则第一个命令将返回非零退出状态,测试将失败,无需进一步操作 有办法解决吗?远程grep配置文件,并根据grep的零或非零状态采取必要的措施另一种方法: git ls-remote some_remote || status=$? if [ $status -ne 0 ]; then git remote add some_remote some@git

在我的Jenkins测试(仅shell)中,我想检查命令的存在状态(在本例中,是git remote的存在):

但是,如果remote不存在,则第一个命令将返回非零退出状态,测试将失败,无需进一步操作


有办法解决吗?

远程grep配置文件,并根据grep的零或非零状态采取必要的措施

另一种方法:

git ls-remote some_remote || status=$?
if [ $status -ne 0 ]; then
  git remote add some_remote some@gitrepo.git
fi
这样,第一行将始终返回true,并且您仍然可以捕获ls remote的状态

git ls-remote some_remote || status=$?
if [ $status -ne 0 ]; then
  git remote add some_remote some@gitrepo.git
fi