问题
- jenkins默认的git拉取代码超时时间为10分钟,如果超过10分钟拉去不成功就报错
处理方案
stage('git pull') {
steps {
// Get some code from a GitHub repository
checkout([$class: 'GitSCM',
branches: [[name: '*/develop']],
extensions: [[$class: 'CheckoutOption', timeout: 20]],
gitTool: 'Default',
userRemoteConfigs: [[ credentialsId: 'gitlab_pjmgm',url: 'https://gitlab.xxx.cn/internal/xxx/xxx-design.git']]]
)
}
}
- extensions中不同的class对应不同的git步骤
- 修改后jenkins构建日志如下,checkout已改为25分钟:
> git fetch --tags --force --progress -- https://gitlab.xxx.cn/internal/xxx/xxx-design.git +refs/heads/*:refs/remotes/origin/* # timeout=10
Checking out Revision 47b4870b70dcd832e84e43a8441d944fb89842f5 (refs/remotes/origin/develop)
> git rev-parse refs/remotes/origin/develop^{commit} # timeout=10
> git config core.sparsecheckout # timeout=10
> git checkout -f 47b4870b70dcd832e84e43a8441d944fb89842f5 # ==timeout=20==