SonarQube Eclipse plugin : change default server configuration - sonarqube

I try to change the default SonarQube server value in SonarQube Eclipse plugin (v3.2)...
Using the pluginCustomization process (argument -pluginCustomization myPrefs.ini in eclipse.ini file), I add the same value as result of eclipse preferences export :
# SonarQube default configuration server
org.sonar.ide.eclipse.core/servers/http\:\\2f\\2fsonar.mycompany.org/auth=true
But after workspace creation, the default value is always http://localhost:9000
This is a bug ? or there is a best common way to do that ?
Thanks for the tips.

24/09/2015 Update : Fixed with SonarQube Eclipse plugin v3.5 (see SONARCLIPS-428).
It is not the answer but a trick ... if you consider :
Having your own plugin with some IStartup process in the Eclipse distribution
You are using a proxy with the same credentials as SonarQube
This code could help you in an earlyStartup() method :
// Plugin dependencies : org.sonar.ide.eclipse.core, org.eclipse.core.net
// Write a process to do this code once (IEclipsePreferences use)
// ...
String userName = null;
String password = null;
// Get first login/password defined in eclipse proxy configuration
BundleContext bc = Activator.getDefault().getBundle().getBundleContext();
ServiceReference<?> serviceReference = bc.getServiceReference(IProxyService.class.getName());
IProxyService proxyService = (IProxyService) bc.getService(serviceReference);
if (proxyService.getProxyData() != null) {
for (IProxyData pd : proxyService.getProxyData()) {
if (StringUtils.isNotBlank(pd.getUserId()) && StringUtils.isNotBlank(pd.getPassword())) {
userName = pd.getUserId();
password = pd.getPassword();
break;
}
}
}
// Configure SonarQube with url and proxy user/password if exist
SonarCorePlugin.getServersManager().addServer("http://sonarqube.mycompany.com", userName, password);
// Store process done in preferences
// ...

Related

How to solve the Error with debug - logging : Cannot access 'io.gatling.gradle.JvmConfigurable.Trait.FieldHelper'?

How to solve the Error with debug - logging : Cannot access 'io.gatling.gradle.JvmConfigurable.Trait.FieldHelper'?
I need to check the log for performance execution on cursor based pagination scripts in jenkins.
but the build.gradle always shows error with log parameters such as at logHttp & logLevel
plugins {
id("scala")
id("io.gatling.gradle") version "3.9.0"
}
gatling {
logHttp = io.gatling.gradle.LogHttp.FAILURES
logLevel = "WARN"
}
repositories {
maven {
url = uri("https://repo1.maven.org/maven2/")
}
}
Error message :
Cannot access 'io.gatling.gradle.JvmConfigurable.Trait.FieldHelper'
which is a supertype of 'io.gatling.gradle.GatlingPluginExtension'.
Check your module classpath for missing or conflicting dependencies
Please help me solve this issue

Adding a custom java library using gradle from gitlab with a provisioned deploy token

I got this working with my public github account where I was using something like this:
maven {
url "https://raw.githubusercontent.com/tvelev92/reactnativeandroidmaven/master/"
}
Then I decided I want it to be private and I put it on my company's gitlab and provisioned an access token however, I cannot figure out how to change build.gradle to accomplish a successful import of the pom file. Here is what I have however, I am receiving a 401 server response.
maven {
url "https://gitlabdev../../mobile/mysdk"
credentials(HttpHeaderCredentials) {
name = "password"
value = "..."
}
authentication {
header(HttpHeaderAuthentication)
}
}
please try:
url "https://raw.githubusercontent.com/tvelev92/reactnativeandroidmaven/raw/master/"

How do I use the DSC package resource to install MongoDB?

I tried what seemed to be the straight-forward approach, and added a Package resource in my node configuration for the MongoDB MSI. I got the following error: "Could not get the https stream for file".
Here's the package configuration I tried:
package MongoDB {
Name = "MongoDB 3.6.11 2008R2Plus SSL (64 bit)"
Path = "https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-3.6.11-signed.msi"
ProductId = "88F7AA23-BDD2-4EBE-9985-EBB5D2E23E83"
Arguments = "ADDLOCAL=`"all`" SHOULD_INSTALL_COMPASS=`"0`" INSTALLLOCATION=`"C:\MongoDB\Server\3.6`""
}
(I had $ConfigurationData references in there, but substituted for literals for simplicity)
I get the following error:
Could not get the https stream for file
Possible TLS version issue? I found that Invoke-WebRequest needed the following to get it to work with that same mongo download URL. Is there a way to do this with the package resource?
[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"
Using nmap to interrogate both nodejs.org and fastdl.mongodb.org (which is actually on cloudfront) it was indeed true that TLS support differed. Node still supports TLS version 1.0, which so happens to work with PowerShell. But MongoDB's site only supports TLS versions 1.1 or 1.2.
As I mentioned in my question, I suspected that setting the .Net security protocol work, and indeed it does. There's no way to add arbitrary script to the DSC package resource, so I needed to make a script block just to run this code, and have the package resource depend on it.
This is what I got to work:
Node $AllNodes.Where{$_.Role -contains 'MongoDBServer'}.NodeName {
Script SetTLS {
GetScript = { #{ Result = $true } }
SetScript = { [Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls" }
TestScript = { $false } #Always run
}
package MongoDB {
Ensure = 'Present'
Name = 'MongoDB 3.6.11 2008R2Plus SSL (64 bit)'
Path = 'https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-3.6.11-signed.msi'
ProductId = ''
Arguments = 'ADDLOCAL="all" SHOULD_INSTALL_COMPASS="0" INSTALLLOCATION="C:\MongoDB\Server\3.6"'
DependsOn = '[Script]SetTLS'
}
...

SonarQube - specify location of sonar.properties

I'm trying to deploy SonarQube on Kubernetes using configMaps.
The latest 7.1 image I use has a config in sonar.properties embedded in $SONARQUBE_HOME/conf/ . The directory is not empty and contain also a wrapper.conf file.
I would like to mount the configMap inside my container in a other location than /opt/sonar/conf/ and specify to sonarQube the new path to read the properties.
Is there a way to do that ? (environment variable ? JVM argument ? ...)
It is not recommended to modify this standard configuration in any way. But we can have a look at the SonarQube sourcecode. In this file you can find this code for reading the configuration file:
private static Properties loadPropertiesFile(File homeDir) {
Properties p = new Properties();
File propsFile = new File(homeDir, "conf/sonar.properties");
if (propsFile.exists()) {
...
} else {
LoggerFactory.getLogger(AppSettingsLoaderImpl.class).warn("Configuration file not found: {}", propsFile);
}
return p;
}
So the conf-path and filename is hard coded and you get a warning if the file does not exist. The home directory is found this way:
private static File detectHomeDir() {
try {
File appJar = new File(Class.forName("org.sonar.application.App").getProtectionDomain().getCodeSource().getLocation().toURI());
return appJar.getParentFile().getParentFile();
} catch (...) {
...
}
So this can also not be changed. The code above is used here:
#Override
public AppSettings load() {
Properties p = loadPropertiesFile(homeDir);
p.putAll(CommandLineParser.parseArguments(cliArguments));
p.setProperty(PATH_HOME.getKey(), homeDir.getAbsolutePath());
p = ConfigurationUtils.interpolateVariables(p, System.getenv());
....
}
This suggests that you can use commandline parameters or environment variables in order to change your settings.
For my problem, I defined environment variable to configure database settings in my Kubernetes deployment :
env:
- name: SONARQUBE_JDBC_URL
value: jdbc:sqlserver://mydb:1433;databaseName=sonarqube
- name: SONARQUBE_JDBC_USERNAME
value: sonarqube
- name: SONARQUBE_JDBC_PASSWORD
valueFrom:
secretKeyRef:
name: sonarsecret
key: dbpassword
I needed to use also ldap plugin but it was not possible to configure environment variable in this case. As /opt/sonarqube/conf/ is not empty, I can't use configMap to decouple configuration from image content. So, I build my own sonarqube image adding the ldap jar plugin and ldap setting in sonar.properties :
# General Configuration
sonar.security.realm=LDAP
ldap.url=ldap://myldap:389
ldap.bindDn=CN=mysa=_ServicesAccounts,OU=Users,OU=SVC,DC=net
ldap.bindPassword=****
# User Configuration
ldap.user.baseDn=OU=Users,OU=SVC,DC=net
ldap.user.request=(&(sAMAccountName={0})(objectclass=user))
ldap.user.realNameAttribute=cn
ldap.user.emailAttribute=mail
# Group Configuration
ldap.group.baseDn=OU=Users,OU=SVC,DC=net
ldap.group.request=(&(objectClass=group)(member={dn}))

What's special about the 'url' field of a Maven repository in gradle?

If I try to replace the URL with a variable substitution in the fragment below, I get an error about trying to apply authentication to a file URL.
What's the syntax?
maven {
url 'https://example.com/artifactory/gradle-release'
credentials {
username = "${artifactory_user}"
password = "${artifactory_password}"
}
}
In other words, changing to:
url '${property_with_url}'
fails.

Resources