> git fetch --tags --force --progress -- https://gitee.com/charlesdengng/qlcgl.git +refs/heads/*:refs/remotes/origin/* # timeout=10 ERROR: Timeout after 10 minutes ERROR: Error fetching remote repo 'origin'一. 出错的原因
$ git clone https://github.com/libgit2/libgit2这会在当前目录下创建一个名为 “libgit2” 的目录,并在这个目录下初始化一个 .git 文件夹, 从远程仓库拉取下所有数据放入 .git 文件夹,然后从中读取最新版本的文件的拷贝。
这个.git文件夹包含我们所有commit的历史版本,以及所有分支。假如仓库有master和dev两个分支,且每个分支占有4MB空间,那么我们下载的仓库代码大小为8MB。再加上 commit 的历史版本,所以下载的仓库代码不止8MB。
environment { // 堆代码 duidaima.com // git仓库地址 git_web_url = 'https://gitee.com/charlesdengng/qlcgl.git' //连接git所需的凭据 git_auth = 'xxxxx-xxxx-xxxx-xxxx-xxxxxxx' //部署到服务器的具体位置 baseDir = '/home/devops/WebApp' } stages { // 拉取代码 stage('拉取代码') { steps { // 拉取前端代码到/var/lib/jenkins/workspace/${JOB_NAME}/web下(具体可在Jenkins web页面的配置页里看见) checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [ // 指定 git 仓库检出后所放位置,相对于/var/lib/jenkins/workspace/${JOB_NAME} [$class: 'RelativeTargetDirectory', relativeTargetDir: 'web'], //克隆选项 [$class: 'CloneOption', depth: 1, noTags: false, reference: '', shallow: true] ], //告诉git拉取的仓库地址以及对应仓库的凭据 userRemoteConfigs: [[credentialsId: "${env.git_auth}" , url: "${env.git_web_url}" ]]]) } } }