jenkins的pipeline使用git默认拉取超时问题处理
// git branch:"test_2023", credentialsId:'b70d62c7-73e4-4706-895b-85b16ad837fd', url:'https://git.code.tencent.com/test.git', changelog:true
script {
// 使用指定的凭据进行 Git 检出
checkout([$class: 'GitSCM',
branches: [[name: 'test_2023']],
userRemoteConfigs: [[credentialsId: 'b70d62c7-73e4-4706-895b-85b16ad837fd', url: 'https://git.code.tencent.com/test.git']],
extensions: [[$class: 'CloneOption', noTags: false, reference: '', shallow: false, timeout: 120]]
])
}
第一行注释是之前的git拉取,执行的默认超时是10分钟,后面几行是解决方式,来提升超时时间
在 Jenkins Pipeline 的 checkout 步骤中,默认情况下是使用 Git 插件的 git fetch 操作,而不是 git pull。虽然 git pull 也是获取远程仓库的更新,但它会自动尝试将这些更新合并到当前分支。在 Jenkins Pipeline 中,git fetch 更常用,因为它更灵活,允许你在获取更新后自行决定是否要进行合并。
如果你确实希望使用 git pull,你可以在 Pipeline 中使用 sh 步骤执行命令