Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ THE SOFTWARE.
<optional>true</optional>
</dependency>

<dependency>
<groupId>com.checkmarx.jenkins</groupId>
<artifactId>checkmarx</artifactId>
<version>8.70.0</version>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>cobertura</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,16 @@ public void perform(Run<?, ?> build, TaskListener listener, EnvVars env) {
logger.log(Level.FINE, "Plugin skipped: JaCoCo");
}

try {
CheckmarxPointGenerator cxGen = new CheckmarxPointGenerator(measurementRenderer, customPrefix, build, timestamp, replaceDashWithUnderscore);
if (cxGen.hasReport()) {
listener.getLogger().println("[InfluxDB Plugin] Checkmarx data found. Writing to InfluxDB...");
addPoints(pointsToWrite, cxGen, listener);
}
} catch (NoClassDefFoundError ignore) {
logger.log(Level.FINE, "Plugin skipped: Checkmarx");
}

try {
PerformancePointGenerator perfGen = new PerformancePointGenerator(measurementRenderer, customPrefix, build, timestamp, replaceDashWithUnderscore);
if (perfGen.hasReport()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package jenkinsci.plugins.influxdb.generators;

import com.checkmarx.jenkins.CxScanResult;

import org.influxdb.dto.Point;

import hudson.model.Run;
import jenkinsci.plugins.influxdb.renderer.MeasurementRenderer;

public class CheckmarxPointGenerator extends AbstractPointGenerator {
private static final String MEASUREMENT_NAME = "checkmarx_data";
private static final String CHECKMARX_HIGH_ISSUES = "high_issues";
private static final String CHECKMARX_MEDIUM_ISSUES = "medium_issues";
private static final String CHECKMARX_LOW_ISSUES = "low_issues";
private static final String CHECKMARX_INFO_ISSUES = "info_issues";

private final Run<?, ?> build;
private final String customPrefix;
private final CxScanResult result;

public CheckmarxPointGenerator(MeasurementRenderer<Run<?,?>> measurementRenderer, String customPrefix, Run<?, ?> build, long timestamp, boolean replaceDashWithUnderscore) {
super(measurementRenderer, timestamp, replaceDashWithUnderscore);
this.build = build;
this.customPrefix = customPrefix;
this.result = build.getAction(CxScanResult.class);
}

public boolean hasReport() {
return this.result != null;
}

public Point[] generate() {
Point point = buildPoint(measurementName(MEASUREMENT_NAME), customPrefix, build)
.addField(CHECKMARX_HIGH_ISSUES, this.result.getHighCount())
.addField(CHECKMARX_MEDIUM_ISSUES, this.result.getMediumCount())
.addField(CHECKMARX_LOW_ISSUES, this.result.getLowCount())
.addField(CHECKMARX_INFO_ISSUES, this.result.getInfoCount())
.build();
return new Point[] {point};
}
}