Commit 7da4521d authored by Pierre-Yves Gibello's avatar Pierre-Yves Gibello
Browse files

Added credentials for sonarqube basic auth

parent 4a1dc48f
......@@ -12,6 +12,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.util.Base64;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
......@@ -308,7 +309,6 @@ public class MainCollector {
/**
* Credentials, in format "user:password" (like curl "-u" parameter)
*
* @param project The project name
* @return The credentials
*/
......@@ -319,7 +319,6 @@ public class MainCollector {
/**
* Credentials, in format "user:password" (like curl "-u" parameter)
*
* @param project The project name
* @return The credentials for the project (or global "omm.credentials" if none)
*/
......@@ -333,7 +332,6 @@ public class MainCollector {
/**
* Credentials, in format "user:password" (like curl "-u" parameter)
*
* @param project The project name
* @return The credentials for the project (or global "omm.credentials" if none)
*/
......@@ -347,7 +345,6 @@ public class MainCollector {
/**
* Retrieves sonar component key
*
* @param project The project name
* @return The sonarqube componentKey (or Id)
*/
......@@ -357,7 +354,6 @@ public class MainCollector {
/**
* Retrieves sonar server URL
*
* @param project The project name
* @return The sonarqube server URL (default https://sonarqube.ow2.org)
*/
......@@ -365,10 +361,19 @@ public class MainCollector {
String server = trim(config.getProperty(project + ".sonarqube.server"));
return (server.length() >= 8 ? server : "https://sonarqube.ow2.org"); // 8=length of "http://a"
}
/**
* Credentials, in format in format "user:password" (like curl "-u" parameter)
* @param project The project name
* @return The credentials
*/
public String getSonarqubeCredentials(String project) {
return trim(config.getProperty(project + ".sonarqube.credentials"))
.replace("`", "\\`").replace("'", "\\'").replace("\"", "\\\"");
}
/**
* Retrieves Scancode URL or local file path
*
* @param project The project name
* @return Scancode URL or local file path
*/
......@@ -378,7 +383,6 @@ public class MainCollector {
/**
* Retrieves OMM URL or local file path
*
* @param project The project name
* @return OMM URL or local file path
*/
......@@ -388,7 +392,6 @@ public class MainCollector {
/**
* Retrieves OMM URL or local file path
*
* @param project The project name
* @return OMM URL or local file path
*/
......@@ -397,8 +400,7 @@ public class MainCollector {
}
/**
* Trim a string that can be bull
*
* Trim a string that can be null
* @param s String to trim
* @return Trimmed string, or "" if null
*/
......@@ -411,7 +413,6 @@ public class MainCollector {
* http://url/ + /complement -> http://url/complement
* http://url + /complement -> http://url/complement
* http://url + complement -> http://url/complement
*
* @param url Base URL
* @param complement Path to append
* @return Complemented URL
......@@ -425,7 +426,6 @@ public class MainCollector {
/**
* Generate script to gather issues data (all projects)
* By convention, data files are gathered in configured output dir, and called [project]_issues.json
*
* @param header Include shell header in script
* @return Script to gather issues data (all projects)
*/
......@@ -500,9 +500,11 @@ public class MainCollector {
public String generateSonarScript(String project) {
String componentKey = getSonarqubeId(project);
String server = getSonarqubeServer(project);
String credentials = getSonarqubeCredentials(project);
if (credentials.length() > 0) credentials = " -u " + credentials;
if (componentKey == null) return null;
else {
return "curl -X GET -H \"Content-Type: application/json\" '"
return "curl -X GET" + credentials + " -H \"Content-Type: application/json\" '"
+ complementUrl(server, "/api/measures/component?metricKeys=coverage,blocker_violations,critical_violations,test_success_density,ncloc&componentKey=")
+ componentKey + "' > " + getOutputDir(true) + project + "_sonar.json";
}
......
......@@ -61,7 +61,7 @@ public class SonarHandler extends JsonDataHandler {
public static void main(String args[]) throws Exception {
// if(args.length < 1) throw new Exception("Usage: JiraHandler <json-file>");
System.out.println("Started: " + new java.util.Date());
SonarHandler handler = new SonarHandler("test", "/tmp/xwiki_sonar.json");
SonarHandler handler = new SonarHandler("test", "/tmp/sonar.json");
handler.run();
System.out.println("Finished: " + new java.util.Date());
if(handler.isDone()) {
......
......@@ -28,7 +28,7 @@ authzforce.sonarqube: org.ow2.authzforce:authzforce-ce-core
authzforce.omm: https://projects.ow2.org/rest/wikis/projects/spaces/authzforce/pages/omm3/objects/ow2.Omm3/0/properties
authzforce.mkt: https://projects.ow2.org/rest/wikis/projects/spaces/authzforce/pages/MKTForm/objects/ow2.MKTFormClass/0/properties
# Clif (missing data)
# Clif (complete)
clif.repo: https://gitlab.ow2.org/clif/clif-legacy
clif.issues.endpoint: https://gitlab.ow2.org/api/v4/projects
clif.issues.project: 192
......@@ -37,7 +37,7 @@ clif.scancode: https://gitlab.ow2.org/ow2/oscar/clif/-/jobs/artifacts/master/raw
clif.omm: https://projects.ow2.org/rest/wikis/projects/spaces/clif/pages/omm3/objects/ow2.Omm3/0/properties
clif.mkt: https://projects.ow2.org/rest/wikis/projects/spaces/clif/pages/MKTForm/objects/ow2.MKTFormClass/0/properties
# Docdoku (missing data)
# Docdoku (complete)
docdoku.repo: https://github.com/docdoku/docdoku-plm
docdoku.issues.endpoint: https://api.github.com/repos/docdoku/docdoku-plm
docdoku.sonarqube: com.docdoku:docdoku-plm
......@@ -57,8 +57,9 @@ fractal.mkt: https://projects.ow2.org/rest/wikis/projects/spaces/fractal/pages/M
# FusionDirectory (missing data)
fusiondirectory.repo: https://github.com/fusiondirectory/fusiondirectory
fusiondirectory.issues.endpoint: https://api.github.com/repos/fusiondirectory/fusiondirectory
##fusiondirectory.sonarqube:
#fusiondirectory.sonarqube.server: https://sonar.fusiondirectory.org
fusiondirectory.sonarqube: FusionDirectory-13
fusiondirectory.sonarqube.server: https://sonar.fusiondirectory.org
#fusiondirectory.sonarqube.credentials: (see included credentials.secret file)
##fusiondirectory.scancode:
fusiondirectory.omm: https://projects.ow2.org/rest/wikis/projects/spaces/fusiondirectory/pages/omm3/objects/ow2.Omm3/0/properties
fusiondirectory.mkt: https://projects.ow2.org/rest/wikis/projects/spaces/fusiondirectory/pages/MKTForm/objects/ow2.MKTFormClass/0/properties
......@@ -88,7 +89,7 @@ joram.sonarqube: org.ow2.joram:parent
joram.omm: https://projects.ow2.org/rest/wikis/projects/spaces/joram/pages/omm3/objects/ow2.Omm3/0/properties
joram.mkt: https://projects.ow2.org/rest/wikis/projects/spaces/joram/pages/MKTForm/objects/ow2.MKTFormClass/0/properties
# Knowage (missing data)
# Knowage (complete)
knowage.repo: https://github.com/KnowageLabs/Knowage-Server
knowage.issues.endpoint: https://api.github.com/repos/KnowageLabs/Knowage-Server
knowage.sonarqube.server: https://sonarcloud.io
......@@ -170,7 +171,7 @@ seedstack.sonarqube: org.seedstack.seed:seed
seedstack.omm: https://projects.ow2.org/rest/wikis/projects/spaces/seedstack/pages/omm3/objects/ow2.Omm3/0/properties
seedstack.mkt: https://projects.ow2.org/rest/wikis/projects/spaces/seedstack/pages/MKTForm/objects/ow2.MKTFormClass/0/properties
# Spoon (missing data)
# Spoon (complete)
spoon.repo: https://github.com/INRIA/spoon
spoon.issues.endpoint: https://api.github.com/repos/INRIA/spoon
spoon.sonarqube: fr.inria.gforge.spoon:spoon-core
......@@ -180,7 +181,7 @@ spoon.scancode: https://gitlab.ow2.org/ow2/oscar/spoon/-/jobs/artifacts/master/r
spoon.omm: https://projects.ow2.org/rest/wikis/projects/spaces/spoon/pages/omm3/objects/ow2.Omm3/0/properties
spoon.mkt: https://projects.ow2.org/rest/wikis/projects/spaces/spoon/pages/MKTForm/objects/ow2.MKTFormClass/0/properties
# Sympa (missing data)
# Sympa (complete)
sympa.repo: https://github.com/sympa-community/sympa
sympa.issues.endpoint: https://api.github.com/repos/sympa-community/sympa
sympa.sonarqube: sympa
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment