我正在将SonarQube集成到Jenkins中。由于历史记录中存在大量二进制文件,我们目前使用浅克隆,因为完全克隆仓库速度较慢。SonarQube需要运行
情况:
我尝试了这个可怕的东西来自定义checkout scm的参数:
但我遇到了这个错误:
报告的问题似乎集中在未提供“存储库名称”上。
结账功能和构建功能都正常,但我仍然获得了一个浅层次的结账。
git blame
,但显然在浅克隆上无法正常工作。我需要一个解决方法,但我不能更改全局Jenkins配置(这会减慢所有构建)。情况:
checkout scm
可以不带参数正常工作。
sh 'git fetch --unshallow
会出现错误,因为它没有凭据。我尝试了这个可怕的东西来自定义checkout scm的参数:
checkout scm: [
$class: 'GitSCM', userRemoteConfigs: [
[url: env.repoURL, credentialsId: 'GitHubEnterprise']
], extensions: [
[$class: 'CheckoutOption', timeout: 60],
[$class: 'CloneOption', noTags: true,
reference: '/var/lib/gitchcache/reference.git',
shallow: false, timeout: 60]
], branches: [
[name: branch]
]
], remoteName: "origin", poll: false, clearWorkspace: true
但我遇到了这个错误:
> git rev-parse PR-42^{commit} # timeout=10
Couldn't find any revision to build. Verify the repository
and branch configuration for this job.
报告的问题似乎集中在未提供“存储库名称”上。
- https://issues.jenkins-ci.org/browse/JENKINS-21845
- https://issues.jenkins-ci.org/browse/JENKINS-29520
- https://issues.jenkins-ci.org/browse/JENKINS-37144
checkout scm: [$class: 'GitSCM',
userRemoteConfigs: [
[url: env.GIT_URL,
refspec: "+refs/pull/${prNumber}/head:refs/remotes/origin/${branch}",
credentialsId: 'GitHubEnterprise']
],
extensions: [
[$class: 'CloneOption',
shallow: false,
timeout: 60]
],
branches: [
[name: branch]
]
]
结账功能和构建功能都正常,但我仍然获得了一个浅层次的结账。
INFO: SCM provider for this project is: git
INFO: 1 files to be analyzed
WARN: Shallow clone detected, no blame information will be provided. You can convert to non-shallow with 'git fetch --unshallow'.
INFO: 0/1 files analyzed
WARN: Missing blame information for the following files:
WARN: * src/main/java/com/example/Example.java
以下是我在Jenkins配置中的项目-GitHub组织下所拥有的内容:
![高级克隆行为](https://istack.dev59.com/448ME.webp)
以下是我想要在特定构建步骤中使用的内容:checkout scm
,但代码中有“未选中”的浅层。
如何在Jenkins中执行git fetch --unshallow?
sh 'git fetch --unshallow'
时遇到了身份验证失败的问题。是否有什么技巧可以从checkout scm中运行Git命令行并带有凭据? - Alain O'Dea