gpt4 book ai didi

git - 克隆到子目录时的 SonarQube Jenkins/git 集成

转载 作者:行者123 更新时间:2023-12-02 04:30:41 24 4
gpt4 key购买 nike

我让 Jenkins 的 git 插件将我的存储库克隆到 WORKSPACE 的子目录中.相应地,我设置

sonar.sources=my/subdir

然而,上述设置似乎并未通知 SCM 检测;和设置
sonar.scm.provider=git

...产量:
ERROR: Not inside a Git work tree: /path/to/my/workspace

如何将我的源位置通知 SonarQube 的 git 插件? (为什么使用 sonar.sources 不够聪明?)

最佳答案

与此斗争了整整 5 个小时。我应该分享对我有用的东西。

使子目录名称与存储库名称相同并从那里运行 mvn sonar 命令

SonarQube 使用来自 Eclipse jgit 的 Java 库进行 git 工作,这会检查 sonar.projectBaseDir 是否有 .git 文件夹和其他一些 git 文件/文件夹等。

注意,当 jenkins Git SCM 克隆时,它会将 repo 的内容直接放在工作区中,不会创建目录

设置:
SonarQube 7.7
Jenkins 声明式管道

示例代码:

checkout([$class: 'GitSCM', branches: [[name: branchName]], 
doGenerateSubmoduleConfigurations: false, extensions: [ [$class: 'RelativeTargetDirectory', relativeTargetDir: "${env.artifactId}"]],
submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'credts', url: 'http://server.com/'+"${env.artifactId}"+'.git']]])


withSonarQubeEnv('Sonar Dev') {
sh 'cd ' + "${env.artifactId}" + ' && mvn -U clean package sonar:sonar '
}

关于git - 克隆到子目录时的 SonarQube Jenkins/git 集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49257285/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com