我继承了SonarQube Linux服务器的职责,该服务器运行着5.1版本,并分析了数十个Unity项目。在将其升级到SQ 6.1之后,我发现对分析非Windows系统上的C#项目的支持在5.5版中被删除,所以我现在将其降级为5.4版。
我随后将Windows系统设置为Jenkins节点和SonarQube服务器。但是,我希望用SonarQube来评估的项目(大部分)是基于macOS开发的,而且(总是)构建在统一中的macOS上,因此缺乏MSbuild解决方案文件。除了在项目中添加特定于Visual的代码之外,我是否有可能在这些约束中使用SonarQube?是否有某种虚拟的解决方案文件,我可以添加到项目中,这样可以在不需要生成工作二进制文件的情况下对它们进行分析(比如解析/标记化而不需要编译/链接)?谢谢。
发布于 2017-06-07 20:05:35
下面是我为通过Jenkins分析SonarQube中的而开发的过程。
1. **General—This project is parameterized**
1. **String parameter** `PROJECTKEY`
2. **String parameter** `PROJECTNAME`
3. **String parameter** `PROJECTVERSION`
1. **General—Restrict where this project can be run** set to the Jenkins build node name you used for your SonarQube server.
2. **Source Code Management**
1. **Repository URL** set to the repository you want to analyze.
2. **Branches to build** set to the main branch, i.e. `refs/heads/master`.
3. **Additional Behaviors—Recursively update submodules** checked as appropriate for your repository.
1. **Build Triggers**
1. **Poll SCM** checked, but no schedule specified.
1. **Build Environment**
1. **Run buildstep before SCM runs—Inject environment variables** set to `HOME=C:\Users\Jenkins` (or as appropriate for your system). This environment variable makes it possible for git to find the correct ssh credentials to use with the Git server. You'll need to put your git private key in `%HOME%\.ssh`; that is documented elsewhere and left as an exercise to the reader.
2. **Use build environment from another project—Template Project** pointing to a second Jenkins job. Mine is called _SonarQube\_Scanner_ (see below).
1. **Build**
1. **Use builders from another project—Template Project** pointing to the same Jenkins job `SonarQube_Scanner`.
1. **Post-build Actions**
1. **Archive the artifacts—Files to archive** set to `log.zip`.
1. **General—Disable this project** checked.
2. **General—Restrict where this project can be run** checked and set to your SonarQube server.
3. **Source Code Management** set to None.
4. **Build Environment—Inject environment variables to the build process** checked. 1. **Properties Content** containsLANG=en\_US.UTF-8
1. **Build**设置FILENAME=%WORKSPACE%\client\Assets\Editor\SQMenuItems.cs REM是的,这个语法工作得更好,并且更易读>%文件名%回波使用UnityEditor;>> %文件名%回送公共静态类SQMenuItems { >> %文件名%回送静态空AssetsOpenCSharpProject() { >> %文件名% ECHO #if UNITY_5 >> %FILENAME% ECHO EditorApplication.ExecuteMenuItem("Assets/Open C#项目“);>> %文件名% ECHO ##en2# >> % EditorApplication.ExecuteMenuItem("Assets/Sync MonoDevelop项目”);>> %文件名% ECHO #endif >> % >> % ECHO EditorApplication.Exit(0);>> %文件名% ECHO }>>%>>% ECHO } "C:\Program Files\Unity_5.5.2\Editor\Unity.exe“-quit -batchmode -nographics -logFile "%WORKSPACE%\log.txt”-buildTarget android -projectPath %工作区%\client -executeMethod SQMenuItems.AssetsOpenCSharpProject "C:\Program \7-zip\7z.exe“-tzip a log.zip log.txt
- SQMenuItems.cs is what triggers Unity to create the `.sln` and `.*proj` files that MSBuild needs. The `.sln` and `.*proj` files are typically in the `.gitignore` file and therefore not in the repository.
1. **SonarQube Scanner for MSBuild - Begin Analysis** 1. **SonarQube Installation** set to the Jenkins build node name you used for your SonarQube server.
2. **Project key** set to `${PROJECTKEY}`.
3. **Project name** set to `${PROJECTNAME}`.
4. **Project version** set to `${PROJECTVERSION}`.
5. **Additional arguments**/d:sonar.exclusions=**\\SQMenuItems.cs
1. **Execute Windows batch command**"C:\Program (x86)\MSBuild\14.0\Bin\MSBuild.exe“/maxcpucount /nr:false /nologo /target:rebuild /verbosity:quiet client\client.sln
- You may need to change `client\client.sln` above to match your environment. I haven't yet tried replacing that with an environment variable defined in the user-facing Jenkins job.
1. **SonarQube Scanner for MSBuild - End Analysis**
SonarQube.Analysis.xml文件特别禁止分配属性sonar.projectName、sonar.projectKey和sonar.projectVersion。
https://stackoverflow.com/questions/43460716
复制相似问题