Skip to content
Permalink
Browse files

use plainer types for AnchoreAction members - Fixes JENKINS-48989

Signed-off-by: Daniel Nurmi <nurmi@anchore.com>
  • Loading branch information
nurmi committed Jan 17, 2018
1 parent e2db0d9 commit e76d6283b97d72c5775143dfc1f4d6fef6cc5f7f
@@ -1,10 +1,11 @@
package com.anchore.jenkins.plugins.anchore;

import com.google.common.base.Function;
import com.google.common.collect.Maps;
//import com.google.common.collect.Maps;
import hudson.model.Action;
import hudson.model.Run;
import java.util.Map;
import java.util.HashMap;
import javax.annotation.Nullable;
import jenkins.model.Jenkins;
import net.sf.json.JSONObject;
@@ -20,7 +21,7 @@
private String gateStatus;
private String gateOutputUrl;
private Map<String, String> queryOutputUrls;
private JSONObject gateSummary;
private String gateSummary;

// For backwards compatibility
@Deprecated
@@ -30,17 +31,29 @@


public AnchoreAction(Run<?, ?> build, String gateStatus, final String jenkinsOutputDirName, String gateReport,
Map<String, String> queryReports, JSONObject gateSummary) {
Map<String, String> queryReports, String gateSummary) {
this.build = build;
this.gateStatus = gateStatus;
this.gateOutputUrl = "../artifact/" + jenkinsOutputDirName + "/" + gateReport;

this.queryOutputUrls = new HashMap<String, String>();
for (Map.Entry<String, String> entry : queryReports.entrySet()) {
String k = entry.getKey();
String v = entry.getValue();
String newv = "../artifact/" + jenkinsOutputDirName + "/" + v;
this.queryOutputUrls.put(k, newv);
}

// original maps conversion method
/*
this.queryOutputUrls = Maps.transformValues(queryReports, new Function<String, String>() {
@Override
public String apply(@Nullable String queryOutput) {
return "../artifact/" + jenkinsOutputDirName + "/" + queryOutput;
}
});
*/
this.gateSummary = gateSummary;
}

@@ -76,7 +89,8 @@ public String getGateOutputUrl() {
}

public JSONObject getGateSummary() {
return gateSummary;
JSONObject ret = JSONObject.fromObject(gateSummary);
return ret;
}

public String getGateReportUrl() {
@@ -820,9 +820,9 @@ public void setupBuildReports() throws AbortException {

if (finalAction != null) {
build.addAction(
new AnchoreAction(build, finalAction.toString(), jenkinsOutputDirName, gateOutputFileName, queryOutputMap, gateSummary));
new AnchoreAction(build, finalAction.toString(), jenkinsOutputDirName, gateOutputFileName, queryOutputMap, gateSummary.toString()));
} else {
build.addAction(new AnchoreAction(build, "", jenkinsOutputDirName, gateOutputFileName, queryOutputMap, gateSummary));
build.addAction(new AnchoreAction(build, "", jenkinsOutputDirName, gateOutputFileName, queryOutputMap, gateSummary.toString()));
}
// } catch (AbortException e) { // probably caught one of the thrown exceptions, let it pass through
// throw e;

0 comments on commit e76d628

Please sign in to comment.
You can’t perform that action at this time.