Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Avoid maybeSonarHome.get #7

Merged
merged 3 commits into from
Feb 5, 2018
Merged

Avoid maybeSonarHome.get #7

merged 3 commits into from
Feb 5, 2018

Conversation

yarosman
Copy link
Contributor

@yarosman yarosman commented Feb 2, 2018

avoid optionality for sonarHome path variable.
allow to set sonar system properties


// Update the external properties file if the sonarUseExternalConfig is set to true.
if (sonarUseExternalConfig.value)
updatePropertiesFile(baseDirectory.value, SonarExternalConfigFileName, version.value)

val args = sonarScannerArgs(sonarUseExternalConfig.value, sonarProperties.value, version.value)
//Allow to set sonar properties via system properties: [https://docs.sonarqube.org/display/SONAR/Analysis+Parameters]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a nice improvement 👍
I'm wondering whether it would be better to populate the system properties first and then merge those with sonarProperties - just in case if you want to overwrite any system settings on a project level.

Copy link
Contributor Author

@yarosman yarosman Feb 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my opinion, system properties are much preferable than project-files properties. In that case you can set project name or other properties for different branches without any files changing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that's a valid point, especially when you e.g. run an analysis on a branch and you want to overwrite some settings in your build pipeline.


// Update the external properties file if the sonarUseExternalConfig is set to true.
if (sonarUseExternalConfig.value)
updatePropertiesFile(baseDirectory.value, SonarExternalConfigFileName, version.value)

val args = sonarScannerArgs(sonarUseExternalConfig.value, sonarProperties.value, version.value)
//Allow to set sonar properties via system properties: [https://docs.sonarqube.org/display/SONAR/Analysis+Parameters]
val ssonarProperties = sonarProperties.value ++ sys.env.filterKeys(_.startsWith("sonar."))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably rename this to something like e.g. mergedSonarProperties.


// Update the external properties file if the sonarUseExternalConfig is set to true.
if (sonarUseExternalConfig.value)
updatePropertiesFile(baseDirectory.value, SonarExternalConfigFileName, version.value)

val args = sonarScannerArgs(sonarUseExternalConfig.value, sonarProperties.value, version.value)
//Allow to set sonar properties via system properties: [https://docs.sonarqube.org/display/SONAR/Analysis+Parameters]
val mergedSonarProperties = sonarProperties.value ++ sys.env.filterKeys(_.startsWith("sonar."))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you were after sys.props instead of sys.env?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch, yes. It is my mistake. I talk about system properties. I will correct it .

@mwz
Copy link
Member

mwz commented Feb 3, 2018

Would you also be able to update README and mention about system properties? An example of how to run sonarScan with system properties would be great.

@mwz
Copy link
Member

mwz commented Feb 5, 2018

That's great, thanks a lot for your contribution @yarosman!
If you can think of any other other improvements, please feel free to open an issue or raise a PR 👍

On a side note, I'm currently working on SonarQube 6.7.1 LTS support in my fork of the sonar-scala plugin, so if you're interested, check out https://github.com/mwz/sonar-scala/tree/sonar-671-lts and https://github.com/mwz/sonarqube-scala-docker in a little while once the new version is ready.

@mwz mwz merged commit 65cc358 into sonar-scala:master Feb 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants