This permits multiple projects to share one database, keeping delta comparisons distinct between them.
#cat cfb.fbp
cd ${SCRIPT_DIR}
-bash -x ./go.sh -c ${SCRIPT_DIR}/config.properties -d cfb -u cfb -p cfb -f cfb.fbp -n jenkins_${JOB_NAME}_${BUILD_NUMBER} -o ${OUT_FILE}
+bash -x ./go.sh -c ${SCRIPT_DIR}/config.properties -d cfb -u cfb -p cfb -f cfb.fbp -j ${JOB_NAME} -n jenkins_${JOB_NAME}_${BUILD_NUMBER} -o ${OUT_FILE}
int m_port; // db port
String m_user; // db user
String m_pass; // db password
+ String m_projName; // project (module) name
String m_buildNum; // build number (version)
boolean m_removeSchema; // purge DB schema
File m_output; // File to which we should write our output (report)
m_port = 5432;
m_pass = "";
m_user = "user";
+ m_projName = null;
m_buildNum = null;
m_removeSchema = false;
m_output = null;
opt.addOption(null, "drop-tables", false, "Remove database schema (drop all data)");
opt.addOption("f", "fbp", true, "FindBugsProject file");
opt.addOption("h", "host", true, "DB hostname");
+ opt.addOption("j", "project", true, "proJect name");
opt.addOption("n", "number", true, "Build number (version)");
opt.addOption("o", "outfile", true, "Output report filename");
opt.addOption("p", "pass", true, "DB password");
if (line.hasOption("h")) {
m_host = line.getOptionValue("h");
}
+ if (line.hasOption("j")) {
+ m_projName = line.getOptionValue("j");
+ }
if (line.hasOption("n")) {
m_buildNum = line.getOptionValue("n");
}
}
Analyzer analyzer = new Analyzer(messageMap);
- Analysis analysis = analyzer.analyze(pw, workDir, m_fbp, m_buildNum);
+ Analysis analysis = analyzer.analyze(pw, workDir, m_fbp, m_projName, m_buildNum);
if (null == analysis) {
pw.println(trans(CfbBundle.ANALYSIS_FAILED));
return;
public class Analysis {
long m_id;
BugCollection m_bugCollection;
+ String m_projectName;
String m_buildNumber;
long m_start; // Date.getTime() when analysis was started
long m_end;
- public Analysis(String buildNumber) {
+ public Analysis(String projectName, String buildNumber) {
m_id = (-1);
m_bugCollection = null;
+ m_projectName = projectName;
m_buildNumber = buildNumber;
m_start = new Date().getTime();
m_end = 0;
public BugCollection getBugCollection() { return m_bugCollection; }
public long getId() { return m_id; }
+ public String getProjectName() { return m_projectName; }
public String getBuildNumber() { return m_buildNumber; }
public Date getStart() { return new Date(m_start); }
public Date getEnd() { return (0 == m_end ? null : new Date(m_end)); } // the end time (when FindBugs was done analyzing)
m_msgMap = msgMap;
}
- public Analysis analyze(PrintWriter pw, File workDir, File fbp, String buildNumber) throws IOException, XmlParseException, SAXException
+ public Analysis analyze(PrintWriter pw, File workDir, File fbp, String projName, String buildNumber)
+ throws IOException, XmlParseException, SAXException
{
- Analysis result = new Analysis(buildNumber);
+ Analysis result = new Analysis(projName, buildNumber);
File fbOutput = outputWorkFile(workDir, fbp);
public static final Column METHODNAME = new Column("METHODNAME", VARCHAR, 256, NULL);
public static final Column METHODROLE = new Column("METHODROLE", VARCHAR, 80, NULL);
public static final Column NAME = new Column("NAME", VARCHAR, 256, NOT_NULL);
+ public static final Column PROJNAME = new Column("PROJNAME", VARCHAR, 80, NOT_NULL);
public static final Column RUNID = new Column("RUNID", INTEGER, -1, NOT_NULL);
public static final Column SECONDLOCID = new Column("SECONDLOCID", INTEGER, -1, NULL);
public static final Column STARTLINE = new Column("STARTLINE", INTEGER, -1, NULL);
private static final Column[] CATEGORIES_COLS = { CATEGORYID, CATEGORY };
private static final Column[] FOUND_COLS = { FOUNDID, RUNID, BUGID, CATEGORYID, FIRSTLOCID, SECONDLOCID, THIRDLOCID, VARID_FK };
private static final Column[] LOCATIONS_COLS = { LOCID, CLASSNAME, METHODNAME, METHODROLE, STARTLINE, ENDLINE };
- private static final Column[] RUNS_COLS = { RUNID, VERSION, STARTTIME, ENDTIME };
+ private static final Column[] RUNS_COLS = { RUNID, PROJNAME, VERSION, STARTTIME, ENDTIME };
private static final Column[] VARIABLES_COLS = { VARID_PK, NAME, VARROLE };
public static final Table BUGS = new Table("BUGS", BUGS_COLS);
Object[][] values = {
{
Long.valueOf(runId),
+ analysis.getProjectName(),
analysis.getBuildNumber(),
analysis.getStart(),
analysis.getEnd()
{
Column[] columns = { CfbSchema.RUNID };
Table[] tables = { CfbSchema.RUNS };
- Condition[] conditions = { new Condition( CfbSchema.STARTTIME, analysis.getStart(), Operation.LESS_THAN ) };
+ Condition[] conditions = {
+ new Condition( CfbSchema.PROJNAME, analysis.getProjectName(), Operation.EQUAL ),
+ new Condition( CfbSchema.STARTTIME, analysis.getStart(), Operation.LESS_THAN )
+ };
Sort[] sorts = { new Sort( CfbSchema.STARTTIME, Sort.Direction.DESCENDING ) };
int limit = 1;
Analysis getAnalysis(Long analysisId) throws SQLException, TypeMismatchException
{
- Column[] columns = { CfbSchema.VERSION, CfbSchema.STARTTIME, CfbSchema.ENDTIME };
+ Column[] columns = { CfbSchema.PROJNAME, CfbSchema.VERSION, CfbSchema.STARTTIME, CfbSchema.ENDTIME };
Table[] tables = { CfbSchema.RUNS };
Condition[] conditions = { new Condition( CfbSchema.RUNID, analysisId, Operation.EQUAL ) };
Row row = rows.get(0);
- String version = row.getString(0);
- java.util.Date start= row.getDate(1);
- java.util.Date end = row.getDate(2);
+ String projName = row.getString(0);
+ String version = row.getString(1);
+ java.util.Date start= row.getDate(2);
+ java.util.Date end = row.getDate(3);
- Analysis prior = new Analysis(version);
+ Analysis prior = new Analysis(projName, version);
prior.setId(analysisId.longValue());
prior.setStart(start);
prior.setEnd(end);
try ( ByteArrayInputStream bais = new ByteArrayInputStream(SAMPLE1_XML.getBytes(utf8)))
{
InputSource inputSource = new InputSource(bais);
- Analysis analysis = new Analysis(null);
+ Analysis analysis = new Analysis(null, null);
analysis.parse(inputSource);
assertNotNull(analysis);