因为是一些个人项目,用SSH配置拿取代码比较麻烦,就试着用Http的方式,我用的Bitbucket,在网站上拿下来的Http链接如下:
https://username@bitbucket.org/hiqianjin/someproject.git
然后在Jenkins Repository URL 中填上上面的地址并配上正确的用户名和密码后会发现:Failed to connect to repository
找了N久,发现不是http方式有问题,是因为我们的地址格式需要变化一下,应该变成:
https://bitbucket.org/hiqianjin/someproject.git
然后就不会报错了。
参考:https://serverfault.com/questions/558666/failed-to-connect-to-repository-401-on-jenkins-codebase-git?newreg=762b1802eb154ff1802e15a898c4c162
GitHub如果遇到这样的问题,试着用同样的方式处理下。