From 74328134cde958ab00a6937d9455b7e8902e4335 Mon Sep 17 00:00:00 2001 From: Veronika Sanko Date: Mon, 20 Aug 2018 18:08:24 +0200 Subject: [PATCH 1/8] Fix problems with working on Unix platforms --- .../plugins/dexter/DexterPublisher.java | 77 ++++++++++--------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/dexter-jenkins/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterPublisher.java b/dexter-jenkins/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterPublisher.java index 607b0952..f65cb482 100644 --- a/dexter-jenkins/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterPublisher.java +++ b/dexter-jenkins/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterPublisher.java @@ -1,33 +1,11 @@ package io.jenkins.plugins.dexter; -import io.jenkins.plugins.dexter.*; -import hudson.Launcher; -import hudson.Extension; -import hudson.model.Action; -import java.util.logging.ConsoleHandler; -import hudson.tasks.*; -import hudson.util.FormValidation; -import hudson.model.AbstractBuild; -import hudson.model.BuildListener; -import hudson.model.AbstractProject; -import net.sf.json.JSONObject; -import org.kohsuke.stapler.DataBoundConstructor; -import org.kohsuke.stapler.StaplerRequest; -import org.kohsuke.stapler.QueryParameter; - -import javax.servlet.ServletException; -import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.FileWriter; import java.io.IOException; -import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.OpenOption; import java.nio.file.Path; @@ -35,6 +13,16 @@ import java.nio.file.StandardOpenOption; import java.util.Scanner; +import org.kohsuke.stapler.DataBoundConstructor; +import org.kohsuke.stapler.StaplerRequest; + +import hudson.Extension; +import hudson.model.AbstractBuild; +import hudson.model.AbstractProject; +import hudson.model.BuildListener; +import hudson.tasks.*; +import net.sf.json.JSONObject; + public class DexterPublisher extends Recorder { private boolean createServer; @@ -238,27 +226,38 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListener lis } else message = "Error saving logs"; } else { + writeToShFile(); - Runtime runtime = Runtime.getRuntime(); - String command = "/home/v.sanko/dexter-server/run.sh"; - try { - runtime.exec(command); - } catch (IOException e) { - e.printStackTrace(); - } writeToFile(); - String commandDexter = pathToBat + "/dexter.sh " + dexterUser + " " + dexterPassword + " > logs.txt \""; try { - runtime.exec(commandDexter); - } catch (IOException e) { + + int ch; + + ProcessBuilder pb = new ProcessBuilder(dexterServerPath + "/run.sh"); + pb.directory(new File(dexterServerPath)); + + Process shellProcess = pb.start(); + + ProcessBuilder pbClient = new ProcessBuilder(pathToBat + "/dexter.sh", dexterUser, dexterPassword); + pbClient.directory(new File(pathToBat)); + + Process shellProcessClient = pbClient.start(); + + InputStreamReader myIStreamReader = new InputStreamReader(shellProcessClient.getInputStream()); + + while ((ch = myIStreamReader.read()) != -1) { + System.out.print((char) ch); + char temp = (char) ch; + message = message + Character.toString(temp); + shellProcess.destroy(); + } + } catch (IOException anIOException) { + System.out.println(anIOException); + } catch (Exception e) { e.printStackTrace(); - } - if (readFile(pathToBat + "/logs.txt")) { - message = stringBufferOfData.toString(); - } else - message = "Error saving logs"; + } } } @@ -296,6 +295,7 @@ private boolean readFile(String filenameRead) { } private void writeToBatFile() { + OpenOption myOpt = StandardOpenOption.CREATE; try { Path fileToWrite = Paths.get(dexterServerPath + "/run.bat"); @@ -315,9 +315,11 @@ private void writeToBatFile() { } private void writeToShFile() { + OpenOption myOpt = StandardOpenOption.CREATE; try { Path fileToWrite = Paths.get(dexterServerPath + "/run.sh"); + BufferedWriter bufwriter = Files.newBufferedWriter(fileToWrite, Charset.forName("UTF-8"), myOpt); bufwriter.write("node server.js -database.host="); bufwriter.write(dexterServer); @@ -334,6 +336,7 @@ private void writeToShFile() { } private void writeToFile() { + OpenOption myOpt = StandardOpenOption.CREATE; try { Path fileToWrite = Paths.get(pathConfig); From 088ce7ad135c609d6150f51c16a2c000548b73cc Mon Sep 17 00:00:00 2001 From: Veronika Sanko Date: Tue, 21 Aug 2018 12:05:29 +0200 Subject: [PATCH 2/8] fix imports --- .../plugins/dexter/DexterPublisher.java | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/dexter-jenkins/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterPublisher.java b/dexter-jenkins/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterPublisher.java index f65cb482..f58bebb3 100644 --- a/dexter-jenkins/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterPublisher.java +++ b/dexter-jenkins/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterPublisher.java @@ -5,7 +5,35 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; + +import io.jenkins.plugins.dexter.*; +import hudson.Launcher; +import hudson.Extension; +import hudson.model.Action; +import java.util.logging.ConsoleHandler; +import hudson.tasks.*; +import hudson.util.FormValidation; +import hudson.model.AbstractBuild; +import hudson.model.BuildListener; +import hudson.model.AbstractProject; +import net.sf.json.JSONObject; +import org.kohsuke.stapler.DataBoundConstructor; +import org.kohsuke.stapler.StaplerRequest; +import org.kohsuke.stapler.QueryParameter; + +import javax.servlet.ServletException; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.OpenOption; import java.nio.file.Path; @@ -13,16 +41,6 @@ import java.nio.file.StandardOpenOption; import java.util.Scanner; -import org.kohsuke.stapler.DataBoundConstructor; -import org.kohsuke.stapler.StaplerRequest; - -import hudson.Extension; -import hudson.model.AbstractBuild; -import hudson.model.AbstractProject; -import hudson.model.BuildListener; -import hudson.tasks.*; -import net.sf.json.JSONObject; - public class DexterPublisher extends Recorder { private boolean createServer; From 4f7cd0672cdaabec9373ee62e17bfaff0d69055a Mon Sep 17 00:00:00 2001 From: Veronika Sanko Date: Tue, 21 Aug 2018 12:12:11 +0200 Subject: [PATCH 3/8] move dexter-jenkins folder to project folder --- dexter-jenkins/dexter-jenkins/.project | 15 - dexter-jenkins/dexter-jenkins/pom.xml | 46 -- .../plugins/dexter/DexterBuildAction.java | 43 -- .../plugins/dexter/DexterProjectAction.java | 56 --- .../plugins/dexter/DexterPublisher.java | 422 ------------------ .../src/main/resources/index.jelly | 4 - .../dexter/DexterBuildAction/index.jelly | 10 - .../dexter/DexterProjectAction/index.jelly | 14 - .../dexter/DexterPublisher/config.jelly | 58 --- .../dexter/DexterPublisher/global.jelly | 5 - 10 files changed, 673 deletions(-) delete mode 100644 dexter-jenkins/dexter-jenkins/.project delete mode 100644 dexter-jenkins/dexter-jenkins/pom.xml delete mode 100644 dexter-jenkins/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterBuildAction.java delete mode 100644 dexter-jenkins/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterProjectAction.java delete mode 100644 dexter-jenkins/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterPublisher.java delete mode 100644 dexter-jenkins/dexter-jenkins/src/main/resources/index.jelly delete mode 100644 dexter-jenkins/dexter-jenkins/src/main/resources/io/jenkins/plugins/dexter/DexterBuildAction/index.jelly delete mode 100644 dexter-jenkins/dexter-jenkins/src/main/resources/io/jenkins/plugins/dexter/DexterProjectAction/index.jelly delete mode 100644 dexter-jenkins/dexter-jenkins/src/main/resources/io/jenkins/plugins/dexter/DexterPublisher/config.jelly delete mode 100644 dexter-jenkins/dexter-jenkins/src/main/resources/io/jenkins/plugins/dexter/DexterPublisher/global.jelly diff --git a/dexter-jenkins/dexter-jenkins/.project b/dexter-jenkins/dexter-jenkins/.project deleted file mode 100644 index 3bfb0d74..00000000 --- a/dexter-jenkins/dexter-jenkins/.project +++ /dev/null @@ -1,15 +0,0 @@ - - - dexter-jenkins - Dexter plugin enables static analysis of the project as a Jenkins build step. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - - - org.eclipse.jdt.core.javabuilder - - - - org.eclipse.jdt.core.javanature - org.eclipse.jdt.groovy.core.groovyNature - - \ No newline at end of file diff --git a/dexter-jenkins/dexter-jenkins/pom.xml b/dexter-jenkins/dexter-jenkins/pom.xml deleted file mode 100644 index f0d9cfce..00000000 --- a/dexter-jenkins/dexter-jenkins/pom.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - 4.0.0 - - org.jenkins-ci.plugins - plugin - 3.4 - - - io.jenkins.plugins - dexter-jenkins - 1.0 - hpi - - 2.7.3 - 7 - - Dexter plugin - - - MIT License - https://opensource.org/licenses/MIT - - - - - - repo.jenkins-ci.org - https://repo.jenkins-ci.org/public/ - - - - - repo.jenkins-ci.org - https://repo.jenkins-ci.org/public/ - - - Dexter plugin enables static analysis of the project as a Jenkins build step. - diff --git a/dexter-jenkins/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterBuildAction.java b/dexter-jenkins/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterBuildAction.java deleted file mode 100644 index c7bfe4ee..00000000 --- a/dexter-jenkins/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterBuildAction.java +++ /dev/null @@ -1,43 +0,0 @@ -package io.jenkins.plugins.dexter; -import hudson.model.AbstractBuild; -import hudson.model.Action; - - -public class DexterBuildAction implements Action { - - private String message; - private AbstractBuild build; - - @Override - public String getIconFileName() { - return "/plugin/testExample/img/build-goals.png"; - } - - @Override - public String getDisplayName() { - return "Static analysis results"; - } - - @Override - public String getUrlName() { - return "analysisResults"; - } - - public String getMessage() { - return this.message; - } - - public int getBuildNumber() { - return this.build.number; - } - - public AbstractBuild getBuild() { - return build; - } - - DexterBuildAction(final String message, final AbstractBuild build) - { - this.message = message; - this.build = build; - } -} diff --git a/dexter-jenkins/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterProjectAction.java b/dexter-jenkins/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterProjectAction.java deleted file mode 100644 index 002ff72a..00000000 --- a/dexter-jenkins/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterProjectAction.java +++ /dev/null @@ -1,56 +0,0 @@ -package io.jenkins.plugins.dexter; - -import hudson.model.AbstractBuild; -import hudson.model.AbstractProject; -import hudson.model.Action; - -import java.util.ArrayList; -import java.util.List; - - -public class DexterProjectAction implements Action { - - private AbstractProject project; - - @Override - public String getIconFileName() { - return "/plugin/testExample/img/project_icon.png"; - } - - @Override - public String getDisplayName() { - return ""; - } - - @Override - public String getUrlName() { - return "dexterAnalysis"; - } - - public AbstractProject getProject() { - return this.project; - } - - public String getProjectName() { - return this.project.getName(); - } - - public List getProjectMessages() { - List projectMessages = new ArrayList(); - List> builds = project.getBuilds(); - String projectMessage=""; - final Class buildClass =DexterBuildAction.class; - - for (AbstractBuild currentBuild : builds) { - int buildNumber = currentBuild.getAction(buildClass).getBuildNumber(); - String message = currentBuild.getAction(buildClass).getMessage(); - projectMessage = String.format("Build # %1$s : %2$s ", buildNumber, message); - projectMessages.add(projectMessage); - } - return projectMessages; - } - - DexterProjectAction(final AbstractProject project) { - this.project = project; - } -} diff --git a/dexter-jenkins/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterPublisher.java b/dexter-jenkins/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterPublisher.java deleted file mode 100644 index f58bebb3..00000000 --- a/dexter-jenkins/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterPublisher.java +++ /dev/null @@ -1,422 +0,0 @@ -package io.jenkins.plugins.dexter; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStreamReader; - -import io.jenkins.plugins.dexter.*; -import hudson.Launcher; -import hudson.Extension; -import hudson.model.Action; -import java.util.logging.ConsoleHandler; -import hudson.tasks.*; -import hudson.util.FormValidation; -import hudson.model.AbstractBuild; -import hudson.model.BuildListener; -import hudson.model.AbstractProject; -import net.sf.json.JSONObject; -import org.kohsuke.stapler.DataBoundConstructor; -import org.kohsuke.stapler.StaplerRequest; -import org.kohsuke.stapler.QueryParameter; - -import javax.servlet.ServletException; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.OpenOption; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.StandardOpenOption; -import java.util.Scanner; - -public class DexterPublisher extends Recorder { - - private boolean createServer; - private String pathDexter; - private String projectFullPath; - private String sourceDir; - private String binDir; - private String headerDir; - private final String analyseFileName; - private final boolean file; - private final boolean folder; - private final boolean project; - private final boolean snapshot; - private String dexterServer; - private String dexterPort; - private String dexterUser; - private String dexterPassword; - private String pathToBat = ""; - private String serverDisc = ""; - private String dexterDisc = ""; - private String dexterServerPath = ""; - private String pathConfig = ""; - private String projectName = ""; - private String projectType = ""; - String message; - - public String getPathConfig() { - return pathConfig; - } - - // Fields in config.jelly must match the parameter names in the - // "DataBoundConstructor" - @DataBoundConstructor - public DexterPublisher(boolean createServer, String dexterServerPath, String dexterServer, String dexterPort, - String dexterUser, String dexterPassword, String pathDexter, String projectFullPath, String sourceDir, - String binDir, String headerDir, String analyseFileName, boolean file, boolean folder, boolean project, - boolean snapshot) { - this.createServer = createServer; - this.dexterServerPath = dexterServerPath; - this.dexterServer = dexterServer; - this.dexterPort = dexterPort; - this.dexterUser = dexterUser; - this.dexterPassword = dexterPassword; - this.pathDexter = pathDexter; - this.projectFullPath = projectFullPath; - this.sourceDir = sourceDir; - this.binDir = binDir; - this.headerDir = headerDir; - this.analyseFileName = analyseFileName; - this.file = file; - this.folder = folder; - this.project = project; - this.snapshot = snapshot; - } - - public boolean isCreateServer() { - return createServer; - } - - public void setCreateServer(boolean createServer) { - this.createServer = createServer; - } - - public String getAnalyseFileName() { - return analyseFileName; - } - - public String getHeaderDir() { - return headerDir; - } - - public static String getFilename() { - return filename; - } - - public String getProjectName() { - return "project"; - } - - public String getProjectFullPath() { - return projectFullPath; - } - - public String getSourceDir() { - return sourceDir; - } - - public String getBinDir() { - return binDir; - } - - public boolean isFile() { - return file; - } - - public boolean isFolder() { - return folder; - } - - public boolean isProject() { - return project; - } - - public boolean isSnapshot() { - return snapshot; - } - - public String getName() { - return pathDexter; - } - - public String getDexterServer() { - return dexterServer; - } - - public String getDexterPort() { - return dexterPort; - } - - public void setDexterPort(String dexterPort) { - this.dexterPort = dexterPort; - } - - public String getDexterUser() { - return dexterUser; - } - - public void setDexterUser(String dexterUser) { - this.dexterUser = dexterUser; - } - - public String getDexterPassword() { - return dexterPassword; - } - - public void setDexterPassword(String dexterPassword) { - this.dexterPassword = dexterPassword; - } - - public void setDexterServer(String dexterServer) { - this.dexterServer = dexterServer; - } - - private static String OS = null; - - public static String getOsName() { - if (OS == null) { - OS = System.getProperty("os.name"); - } - return OS; - } - - public static boolean isWindows() { - return getOsName().startsWith("Windows"); - } - - @Override - public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) { - pathToBat = pathDexter + "/bin"; - pathConfig = pathDexter + "/bin/dexter_cfg.json"; - projectName = getProjectName(); - serverDisc = dexterServerPath.substring(0, 2); - dexterDisc = pathDexter.substring(0, 2); - if (file) { - projectType = "FILE"; - } - if (folder) { - projectType = "FOLDER"; - } - if (project) { - projectType = "PROJECT"; - } - if (snapshot) { - projectType = "SNAPSHOT"; - } - - if (isCreateServer()) { - if (isWindows()) { - writeToBatFile(); - Runtime runtime = Runtime.getRuntime(); - String command = "cmd /c start /wait cmd.exe /K " + "\"cd " + dexterServerPath + " && " + serverDisc - + " && run.bat \""; - try { - runtime.exec(command); - } catch (IOException e) { - e.printStackTrace(); - } - - writeToFile(); - - String commandDexter = "cmd /c start cmd.exe /K " + "\"cd " + pathToBat + " && " + dexterDisc - + " && dexter.bat " + dexterUser + " " + dexterPassword + " > logs.txt \""; - try { - runtime.exec(commandDexter); - } catch (IOException e) { - e.printStackTrace(); - } - - if (readFile(pathToBat + "//logs.txt")) { - message = stringBufferOfData.toString(); - } else - message = "Error saving logs"; - } else { - - writeToShFile(); - writeToFile(); - - try { - - int ch; - - ProcessBuilder pb = new ProcessBuilder(dexterServerPath + "/run.sh"); - pb.directory(new File(dexterServerPath)); - - Process shellProcess = pb.start(); - - ProcessBuilder pbClient = new ProcessBuilder(pathToBat + "/dexter.sh", dexterUser, dexterPassword); - pbClient.directory(new File(pathToBat)); - - Process shellProcessClient = pbClient.start(); - - InputStreamReader myIStreamReader = new InputStreamReader(shellProcessClient.getInputStream()); - - while ((ch = myIStreamReader.read()) != -1) { - System.out.print((char) ch); - char temp = (char) ch; - message = message + Character.toString(temp); - shellProcess.destroy(); - } - } catch (IOException anIOException) { - System.out.println(anIOException); - } catch (Exception e) { - e.printStackTrace(); - - } - } - } - - DexterBuildAction buildAction = new DexterBuildAction(message, build); - build.addAction(buildAction); - return true; - } - - static StringBuffer stringBufferOfData = new StringBuffer(); - static String filename = null; - static Scanner sc = new Scanner(System.in, "UTF-8"); - - private boolean readFile(String filenameRead) { - filename = filenameRead; - Scanner fileToRead = null; - try { - stringBufferOfData.replace(0, stringBufferOfData.length(), " "); - fileToRead = new Scanner(new File(filename), "UTF-8"); - for (String line; fileToRead.hasNextLine() && (line = fileToRead.nextLine()) != null;) { - System.out.println(line); - stringBufferOfData.append(line).append("\n"); - } - fileToRead.close(); - return true; - } catch (FileNotFoundException ex) { - System.out.println("The file " + filename + " could not be found! " + ex.getMessage()); - return false; - } finally { - if (fileToRead != null) { - fileToRead.close(); - } - return true; - } - - } - - private void writeToBatFile() { - - OpenOption myOpt = StandardOpenOption.CREATE; - try { - Path fileToWrite = Paths.get(dexterServerPath + "/run.bat"); - BufferedWriter bufwriter = Files.newBufferedWriter(fileToWrite, Charset.forName("UTF-8"), myOpt); - bufwriter.write("node server.js -database.host="); - bufwriter.write(dexterServer); - bufwriter.write(" -p="); - bufwriter.write(dexterPort); - bufwriter.write(" -database.name=my_dexter_db -database.user="); - bufwriter.write(dexterUser); - bufwriter.write(" -database.password="); - bufwriter.write(dexterPassword); - bufwriter.close(); - } catch (Exception e) { - System.out.println("Error occured while attempting to write to file: " + e.getMessage()); - } - } - - private void writeToShFile() { - - OpenOption myOpt = StandardOpenOption.CREATE; - try { - Path fileToWrite = Paths.get(dexterServerPath + "/run.sh"); - - BufferedWriter bufwriter = Files.newBufferedWriter(fileToWrite, Charset.forName("UTF-8"), myOpt); - bufwriter.write("node server.js -database.host="); - bufwriter.write(dexterServer); - bufwriter.write(" -p="); - bufwriter.write(dexterPort); - bufwriter.write(" -database.name=my_dexter_db -database.user="); - bufwriter.write(dexterUser); - bufwriter.write(" -database.password="); - bufwriter.write(dexterPassword); - bufwriter.close(); - } catch (Exception e) { - System.out.println("Error occured while attempting to write to file: " + e.getMessage()); - } - } - - private void writeToFile() { - - OpenOption myOpt = StandardOpenOption.CREATE; - try { - Path fileToWrite = Paths.get(pathConfig); - BufferedWriter bufwriter = Files.newBufferedWriter(fileToWrite, Charset.forName("UTF-8"), myOpt); - bufwriter.write("{\n"); - bufwriter.write("\"dexterHome\":\"" + pathDexter + "\", \n"); - bufwriter.write("\"dexterServerIp\":\"" + dexterServer + "\", \n"); - bufwriter.write("\"dexterServerPort\":\"" + dexterPort + "\", \n"); - bufwriter.write("\"projectName\":\"" + projectName + "\", \n"); - bufwriter.write("\"projectFullPath\":\"" + projectFullPath + "\", \n"); - bufwriter.write("\"sourceDir\":[\"" + sourceDir + "\"], \n"); - bufwriter.write("\"headerDir\":[\"" + headerDir + "\"], \n"); - bufwriter.write("\"sourceEncoding\":\"UTF-8\", \n"); - bufwriter.write("\"libDir\":[], \n"); - bufwriter.write("\"binDir\":\"\", \n"); - bufwriter.write("\"modulePath\":\"\", \n"); - bufwriter.write("\"fileName\":[\"" + analyseFileName + "\"], \n"); - bufwriter.write("\"type\":\"" + projectType + "\" \n"); - bufwriter.write("}\n"); - bufwriter.close(); - } catch (Exception e) { - System.out.println("Error occured while attempting to write to file: " + e.getMessage()); - } - } - - @Override - public DescriptorImpl getDescriptor() { - return (DescriptorImpl) super.getDescriptor(); - } - - @Override - public BuildStepMonitor getRequiredMonitorService() { - return BuildStepMonitor.NONE; - } - - @Override - public Action getProjectAction(AbstractProject project) { - return new DexterProjectAction(project); - } - - @Extension - public static final class DescriptorImpl extends BuildStepDescriptor { - - public DescriptorImpl() { - load(); - } - - public boolean isApplicable(Class aClass) { - - return true; - } - - public String getDisplayName() { - return "Dexter Static Analysis"; - } - - @Override - public boolean configure(StaplerRequest req, JSONObject formData) throws FormException { - - save(); - return super.configure(req, formData); - } - - } -} \ No newline at end of file diff --git a/dexter-jenkins/dexter-jenkins/src/main/resources/index.jelly b/dexter-jenkins/dexter-jenkins/src/main/resources/index.jelly deleted file mode 100644 index 7e80ab20..00000000 --- a/dexter-jenkins/dexter-jenkins/src/main/resources/index.jelly +++ /dev/null @@ -1,4 +0,0 @@ - -
- Dexter static analysis tool -
diff --git a/dexter-jenkins/dexter-jenkins/src/main/resources/io/jenkins/plugins/dexter/DexterBuildAction/index.jelly b/dexter-jenkins/dexter-jenkins/src/main/resources/io/jenkins/plugins/dexter/DexterBuildAction/index.jelly deleted file mode 100644 index df1cc9af..00000000 --- a/dexter-jenkins/dexter-jenkins/src/main/resources/io/jenkins/plugins/dexter/DexterBuildAction/index.jelly +++ /dev/null @@ -1,10 +0,0 @@ - - - - - -

${it.displayName}

-

Build #${it.buildNumber}'s Output: ${it.message}

-
-
-
\ No newline at end of file diff --git a/dexter-jenkins/dexter-jenkins/src/main/resources/io/jenkins/plugins/dexter/DexterProjectAction/index.jelly b/dexter-jenkins/dexter-jenkins/src/main/resources/io/jenkins/plugins/dexter/DexterProjectAction/index.jelly deleted file mode 100644 index 7624f3e4..00000000 --- a/dexter-jenkins/dexter-jenkins/src/main/resources/io/jenkins/plugins/dexter/DexterProjectAction/index.jelly +++ /dev/null @@ -1,14 +0,0 @@ - - - - - -

${it.DisplayName}

-

For ${it.ProjectName}:

- - -

${projectMessage}

-
-
-
-
\ No newline at end of file diff --git a/dexter-jenkins/dexter-jenkins/src/main/resources/io/jenkins/plugins/dexter/DexterPublisher/config.jelly b/dexter-jenkins/dexter-jenkins/src/main/resources/io/jenkins/plugins/dexter/DexterPublisher/config.jelly deleted file mode 100644 index 903bdcd5..00000000 --- a/dexter-jenkins/dexter-jenkins/src/main/resources/io/jenkins/plugins/dexter/DexterPublisher/config.jelly +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/dexter-jenkins/dexter-jenkins/src/main/resources/io/jenkins/plugins/dexter/DexterPublisher/global.jelly b/dexter-jenkins/dexter-jenkins/src/main/resources/io/jenkins/plugins/dexter/DexterPublisher/global.jelly deleted file mode 100644 index 9a21b9ba..00000000 --- a/dexter-jenkins/dexter-jenkins/src/main/resources/io/jenkins/plugins/dexter/DexterPublisher/global.jelly +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file From 8509cbc4d3eb0ce1e18edc0fb33294c673cacd98 Mon Sep 17 00:00:00 2001 From: Veronika Sanko Date: Tue, 21 Aug 2018 12:22:14 +0200 Subject: [PATCH 4/8] move dexter jenkins folder to project --- .../dexter-jenkins/dexter-jenkins/.project | 15 +++++ .../dexter-jenkins/bin/.project | 15 +++++ .../dexter-jenkins/dexter-jenkins/bin/pom.xml | 46 ++++++++++++++ .../plugins/dexter/DexterBuildAction.class | Bin 0 -> 2577 bytes .../plugins/dexter/DexterProjectAction.class | Bin 0 -> 3049 bytes .../DexterPublisher$DescriptorImpl.class | Bin 0 -> 5608 bytes .../plugins/dexter/DexterPublisher.class | Bin 0 -> 9154 bytes .../bin/src/main/resources/index.jelly | 4 ++ .../dexter/DexterBuildAction/index.jelly | 10 +++ .../dexter/DexterProjectAction/index.jelly | 14 +++++ .../dexter/DexterPublisher/config.jelly | 58 ++++++++++++++++++ .../dexter/DexterPublisher/global.jelly | 5 ++ 12 files changed, 167 insertions(+) create mode 100644 project/dexter-jenkins/dexter-jenkins/.project create mode 100644 project/dexter-jenkins/dexter-jenkins/bin/.project create mode 100644 project/dexter-jenkins/dexter-jenkins/bin/pom.xml create mode 100644 project/dexter-jenkins/dexter-jenkins/bin/src/main/java/io/jenkins/plugins/dexter/DexterBuildAction.class create mode 100644 project/dexter-jenkins/dexter-jenkins/bin/src/main/java/io/jenkins/plugins/dexter/DexterProjectAction.class create mode 100644 project/dexter-jenkins/dexter-jenkins/bin/src/main/java/io/jenkins/plugins/dexter/DexterPublisher$DescriptorImpl.class create mode 100644 project/dexter-jenkins/dexter-jenkins/bin/src/main/java/io/jenkins/plugins/dexter/DexterPublisher.class create mode 100644 project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/index.jelly create mode 100644 project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/io/jenkins/plugins/dexter/DexterBuildAction/index.jelly create mode 100644 project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/io/jenkins/plugins/dexter/DexterProjectAction/index.jelly create mode 100644 project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/io/jenkins/plugins/dexter/DexterPublisher/config.jelly create mode 100644 project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/io/jenkins/plugins/dexter/DexterPublisher/global.jelly diff --git a/project/dexter-jenkins/dexter-jenkins/.project b/project/dexter-jenkins/dexter-jenkins/.project new file mode 100644 index 00000000..3bfb0d74 --- /dev/null +++ b/project/dexter-jenkins/dexter-jenkins/.project @@ -0,0 +1,15 @@ + + + dexter-jenkins + Dexter plugin enables static analysis of the project as a Jenkins build step. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + + + org.eclipse.jdt.core.javabuilder + + + + org.eclipse.jdt.core.javanature + org.eclipse.jdt.groovy.core.groovyNature + + \ No newline at end of file diff --git a/project/dexter-jenkins/dexter-jenkins/bin/.project b/project/dexter-jenkins/dexter-jenkins/bin/.project new file mode 100644 index 00000000..3bfb0d74 --- /dev/null +++ b/project/dexter-jenkins/dexter-jenkins/bin/.project @@ -0,0 +1,15 @@ + + + dexter-jenkins + Dexter plugin enables static analysis of the project as a Jenkins build step. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + + + org.eclipse.jdt.core.javabuilder + + + + org.eclipse.jdt.core.javanature + org.eclipse.jdt.groovy.core.groovyNature + + \ No newline at end of file diff --git a/project/dexter-jenkins/dexter-jenkins/bin/pom.xml b/project/dexter-jenkins/dexter-jenkins/bin/pom.xml new file mode 100644 index 00000000..f0d9cfce --- /dev/null +++ b/project/dexter-jenkins/dexter-jenkins/bin/pom.xml @@ -0,0 +1,46 @@ + + + 4.0.0 + + org.jenkins-ci.plugins + plugin + 3.4 + + + io.jenkins.plugins + dexter-jenkins + 1.0 + hpi + + 2.7.3 + 7 + + Dexter plugin + + + MIT License + https://opensource.org/licenses/MIT + + + + + + repo.jenkins-ci.org + https://repo.jenkins-ci.org/public/ + + + + + repo.jenkins-ci.org + https://repo.jenkins-ci.org/public/ + + + Dexter plugin enables static analysis of the project as a Jenkins build step. + diff --git a/project/dexter-jenkins/dexter-jenkins/bin/src/main/java/io/jenkins/plugins/dexter/DexterBuildAction.class b/project/dexter-jenkins/dexter-jenkins/bin/src/main/java/io/jenkins/plugins/dexter/DexterBuildAction.class new file mode 100644 index 0000000000000000000000000000000000000000..3580e8249f450ad75c21e0f88291cd31aa43e398 GIT binary patch literal 2577 zcmbtWX>SuT5FNLrIViLg%2AG*awP>e9OXtx8ZIl#6yIvpjJoEf!oL|4c{Q!VPcvyfD0*{RLYY`K&w!u2ACRA;M%S|Co zEe?~GYXkn-a$S3wHqR3g21~vbN)}*@z*K4#GTExVYi@Ag5-3F67}nwhij5Vkg={?` zaH#1F2~0MYn#OA8+Y||BN-LrznN2hr9Pgcdy0GvJS4_6Jt@}#879oGjB3xIlRCl4z zzE7kT5wFXRFrpdqB`K9<&P9Vu8}B+?YY}in8hfDvUVvkWx$E~Ut(7jqaRTy#)ZD1B z!vpH8C>CLgLSwBEHZqTCxwMT&ede~IO-^@gtfGwCt(ccfS>XK_m0=2ICg3ETA~60` zNMWB5n5i^&UF*_UU30_<$=@bXlj~K6-Vm5>D4&IEObgfV4vyKjz^I=z4t%Ug(@`Y+ zr7&^Gwz_=dzy}@fc9ydvE&?SG4#3(VbPU8<=3J_sj0^&!m1?~RmkBKQcf_4ukNEnZ z4$2p!PIn@33U(vq z2sg>-tpU7WZSz#=)QQz|`R`@y`>bg$#to5)p1;%B*wErH_fWu2qEnPYKQi z)bm4T3|+@mH|0{!F8eC!|8@yDZtNV0nZJp}i_Qz>bt|FQt%P1y3Fm2`xS=ljBWC?J zwa5kk9AjjE+hYQHuC971L;Is;QHm&5+R}Cs7$tK!9CTGynsWf?ki}^j&6Vm=9134p zYLb|1tew(Wo%mL1nyI2vbpl9az}K;i1s+{ajCG`?W+(_DJ8F|thOD-G5eBQJL%F-J zhW;jLi2TG`W<@31=kA6gaB|O8nQ8zlMqN5;gt1)OH-c-X{q|M??hrWAvt0oe@k-df zX7A&7<}!haWnm0nsjGO)7`O;n{_rv%!QUYmPrnLK#L-gvU4{aFABG8>KY}CU*gJ~t zBtDC1Nw6({hpCU#(_i7lPwb7rX?(kNfOco_J&~<~SvZS50_P5hHkFHZ{(xvRxo8(s zZ}&zwmlNG=F2Y5a#~Ak_T*^V1%SE^XSCPex|7$r&l^mq`93;R$1`9h#*LRTId1q&K fBL|7(AdP~DHX~4jTi60Tz^4pja2xKzJsAB1OiRI< literal 0 HcmV?d00001 diff --git a/project/dexter-jenkins/dexter-jenkins/bin/src/main/java/io/jenkins/plugins/dexter/DexterProjectAction.class b/project/dexter-jenkins/dexter-jenkins/bin/src/main/java/io/jenkins/plugins/dexter/DexterProjectAction.class new file mode 100644 index 0000000000000000000000000000000000000000..92ee371d943b83ea7f13e341737abf89a31226b0 GIT binary patch literal 3049 zcmcImTXP#V6h3m(+Fnf3rYXHr)Bq(8u%=L2N1Gk3!ndQ3kC|iEkYL^FgJ+MN_I?NC_pYcUZ4mwZz?v6k`$*Blj z=&kpS)hw_D;|hW1rWifs#Lph(BgAQZ6jDdk2y>trl{C zgx7ybr4=#n%8@XlAMtf5m1RylL%{1j8F8&e$dPpBp$d5&<`De==m)KpZomZs@~PC^ zsA$AP8mKrCQHDa%7KDw>x72G+&}hJ%7~1D_pT{c7s2wNVYv$S=PvpTYTx`JtTq1C8 zRY+mi&>c(DHnz7>;hvEEaT@oz-eRZ?f%%>aShUTwaQotL#tsEq{ax=3Vv3HMMdv>f zCW+WM_q~S)Pjz&#DS}DhB1UC8!k4E{v$!^Z68OD>pASJE@5$z=sB`lQ1Dr(-_>e$a zL8&THJ*_VD=-EP-4Q>n@aExCA-PaSwVkmADpR3dFVr``XOQd$Eg60nF1Rqv1?rq_$ zYt6=Q3#|Dr6`$c8zF^rF4gDE(0vUJ6grK z|1HJ4korO9!5wS{#%nquA;%+km9StBvxY7TQo)>zcMi8NlKu#A&kL+W(&s$1Gj*{8643F)Zi?f!?ljP8Z>al@d-Tq zeg{w7O$*m|@pl(F2(I2=F#GHL`9EO(Iqquk9{xKzfH}B~|E-(~uE15?5xDl6XbYui z*IyIuYAM=80}Xh zCS-M&?Xjv*)m<*12x+Qum~`AT;QN;A>RS4El(a%&x?JB`6*fO}9RFm*(`uC>wyxI(6N6>or7cbm`BdnprNU4l1EEo+ z@Blxxx#rSGA#JT99DkeOw}4jskQqbUBIG6$6mXn!pJL`eVI5BAg{t%nROuP0k{M{8 z28tW%#7E5fU20KLz8|B^p6oH)O-L?i+FheyIU!3*QhZHbqA=n`l(5 zJV3H|x4zuMA1L$fBduJ^q_%|13h*+4_4At{t`{U(ex!5^95gHO;|eMlaBiULl0%Yz3ex^*cE4;D|f z`?6huK)=j>gge-vGw=am-w%6@0OR;}87A=VrM<^X_y$n=1qxr!lzxKA-*7YrQ+RhY zfY&tMCo?K|0cO&<>oAK{bND_6FZMZ&;W*>;(jX`DeJ-aP@Cx!C)a7OlhaYk|yaul$ zwp%FMVWTjQZ%+3&@OjABVb3(Xlf(DN9KI9q7OokCw|gkdeZC7g{|;UNckwErBm(b3 Z1#ZCSIG({oSw(wO_y|6R`|ugm{siA7E-3&2 literal 0 HcmV?d00001 diff --git a/project/dexter-jenkins/dexter-jenkins/bin/src/main/java/io/jenkins/plugins/dexter/DexterPublisher.class b/project/dexter-jenkins/dexter-jenkins/bin/src/main/java/io/jenkins/plugins/dexter/DexterPublisher.class new file mode 100644 index 0000000000000000000000000000000000000000..1f39ac2c8b42f4f2a71d4a8b1b30bb17e173c0e4 GIT binary patch literal 9154 zcmeHM&2t<_6@Rl4p53)%*}^dx1DQApk({vN!w?cV27Opq$=Xu9vXeM`jb?gx+n$}- zbk9l_0RkkDqBwBiz<~n?4jede;E*aP$SGA62mTQL2#Q}%_kKk!?T$+cq#{?zZ+iOm zuitz9UQhRL|M{Q4{GEs{(pxSS9C}KMV7}$^c>a#R?a%XM{tk=p@>tHdqfSG~kljm} zm|w}nMrSMHvdM%?6Aqos#zcPHm|x$z!-CYI$v`kaWi=+YnQ+Lt?NGVxr%gTFp_yub zOf3~WZY(%7-4=-&zS@bR4JbQQl1WDdY=r~k*cOkohf*G?u4Jn`V%Pl^ zb7-QDM`+iR2ucpQ2GpUVjQzH3CdxeRP1n4#Zf+z3eWr0!s?jG*k1yp;B0^ZCyx2^Z ze5DB$xVOS(&>N;3CkOGhE1CPtNnGa*hmISgw8`Dp=58C7yDcWA-@sF0y@p81EIdn{ zdYy^&`ih_WFsrJArr#oTMdfvz1)!j;DOGEMAID6fZ>qskWkYxJ)3bB7=ua#sA#-UK z>(F1DD?%iqNEaMhy%`H8lW3cTUXZlfJn~bX#2!4^idgFzuUyhLd1~S$^|qMT8;~ZR z@1=0BT&BnA$w~S=Rj@{vc+Atw4m~)#*PyvuFr><3cD>WuVq(+BEGlo3z>jYEf~&T9 zIgvKGbm-~oeI_wt^sm|5drkN-zPXKmDs<;=bmEk^*jl{JB}c3l)uLoehEScUsytds zI&p}sK!$aKG!Y9$ddivp_rVJ-)k<$RS+<;>%9M(#{K{riBs*$REbCwK)>4m4kH;Yw zDDY?(seyE6ae!>9i=>72s~z-(UL}Z7Y@W(zsV527_7~-D_jc!STqGirVZdnfd#p>G^r9jg3LO$`gxw9~!mM);Bw$ zL{aZ8;UOOnQ!877PRgSXa?-A|a9Cr)lDuC3C^FW0T3m**SgeSLbteFZ5Q1c?Eqxkjgcs(&AErBhae)nprNbfeOQe;r>co z8VK-nT-JL0pNoNdnrS@gy{AhCD!R<C~atFxVrNtfDSoDU~b zNQL3hxdaAuYABIi>R>nPzA|xeX$Ks&4uwlFacU^XU3v`xeQ%Im`XSP@TNW<8j#l?N z>e5e8O@^3v=?yrocWHg%aOr15zoqCtC|%R1ANBKqq=(6&2k^_yIV#Y{=op>~f2iL+c{Ebs)=srN>{MnR}a_cn7Tl z&Ex-LS-j z2&@Q~=-B~;LeB;pLc@x1IY&(HS`ogU10k^>l;|5hgbP^~b|Yz97nva_PaRt9jT^n5 zJC>OpTFQa&niXL=2g2)Cgq0i!Z&(qoa!=J1O8#!$F zvlZcm90+e)5K45T=f&uq>2Dc=+L=mJ>*ezBxJ}E>{%&uaL$~O~f$z&p!0LV-CVG4O z%NC4(Sga>{g}yazCOMB-5DN5d`py7C{|oiqy*4<{S`qvl2rpO>wsIiUEeH+;6z&t% zzDJg*I`;jVQT@Kq-n81*peDX~9IIQPJH3;|;L7*E>NXpHVL_dsyBS_YEl8pme`Ty= fg1=YkEd3nqGk7B?rER)L-=`nYkLbtrQ+o5im=UNf literal 0 HcmV?d00001 diff --git a/project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/index.jelly b/project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/index.jelly new file mode 100644 index 00000000..7e80ab20 --- /dev/null +++ b/project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/index.jelly @@ -0,0 +1,4 @@ + +
+ Dexter static analysis tool +
diff --git a/project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/io/jenkins/plugins/dexter/DexterBuildAction/index.jelly b/project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/io/jenkins/plugins/dexter/DexterBuildAction/index.jelly new file mode 100644 index 00000000..df1cc9af --- /dev/null +++ b/project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/io/jenkins/plugins/dexter/DexterBuildAction/index.jelly @@ -0,0 +1,10 @@ + + + + + +

${it.displayName}

+

Build #${it.buildNumber}'s Output: ${it.message}

+
+
+
\ No newline at end of file diff --git a/project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/io/jenkins/plugins/dexter/DexterProjectAction/index.jelly b/project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/io/jenkins/plugins/dexter/DexterProjectAction/index.jelly new file mode 100644 index 00000000..7624f3e4 --- /dev/null +++ b/project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/io/jenkins/plugins/dexter/DexterProjectAction/index.jelly @@ -0,0 +1,14 @@ + + + + + +

${it.DisplayName}

+

For ${it.ProjectName}:

+ + +

${projectMessage}

+
+
+
+
\ No newline at end of file diff --git a/project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/io/jenkins/plugins/dexter/DexterPublisher/config.jelly b/project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/io/jenkins/plugins/dexter/DexterPublisher/config.jelly new file mode 100644 index 00000000..903bdcd5 --- /dev/null +++ b/project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/io/jenkins/plugins/dexter/DexterPublisher/config.jelly @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/io/jenkins/plugins/dexter/DexterPublisher/global.jelly b/project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/io/jenkins/plugins/dexter/DexterPublisher/global.jelly new file mode 100644 index 00000000..9a21b9ba --- /dev/null +++ b/project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/io/jenkins/plugins/dexter/DexterPublisher/global.jelly @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file From aa4d413ef91019a091bf91a58f8b9099836591b1 Mon Sep 17 00:00:00 2001 From: Veronika Sanko Date: Tue, 21 Aug 2018 12:27:36 +0200 Subject: [PATCH 5/8] remove unnecessary file --- .../dexter/DexterPublisher$DescriptorImpl.class | Bin 5608 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 project/dexter-jenkins/dexter-jenkins/bin/src/main/java/io/jenkins/plugins/dexter/DexterPublisher$DescriptorImpl.class diff --git a/project/dexter-jenkins/dexter-jenkins/bin/src/main/java/io/jenkins/plugins/dexter/DexterPublisher$DescriptorImpl.class b/project/dexter-jenkins/dexter-jenkins/bin/src/main/java/io/jenkins/plugins/dexter/DexterPublisher$DescriptorImpl.class deleted file mode 100644 index d5d1de3bb4070b0872be358548fe62655d66b681..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5608 zcmeHL-E$i?5MQNf&UVu#qzO<8R1F0j3N{~wLLD-b&uJJFcjC|)c$4pBTj`y2NV<^x zA-wRypTP{wz&n2w!|Kj)K75G{QwkmOa39jGcK5fd-P7*xfBgI_0NjHm55@>=80}Xh zCS-M&?Xjv*)m<*12x+Qum~`AT;QN;A>RS4El(a%&x?JB`6*fO}9RFm*(`uC>wyxI(6N6>or7cbm`BdnprNU4l1EEo+ z@Blxxx#rSGA#JT99DkeOw}4jskQqbUBIG6$6mXn!pJL`eVI5BAg{t%nROuP0k{M{8 z28tW%#7E5fU20KLz8|B^p6oH)O-L?i+FheyIU!3*QhZHbqA=n`l(5 zJV3H|x4zuMA1L$fBduJ^q_%|13h*+4_4At{t`{U(ex!5^95gHO;|eMlaBiULl0%Yz3ex^*cE4;D|f z`?6huK)=j>gge-vGw=am-w%6@0OR;}87A=VrM<^X_y$n=1qxr!lzxKA-*7YrQ+RhY zfY&tMCo?K|0cO&<>oAK{bND_6FZMZ&;W*>;(jX`DeJ-aP@Cx!C)a7OlhaYk|yaul$ zwp%FMVWTjQZ%+3&@OjABVb3(Xlf(DN9KI9q7OokCw|gkdeZC7g{|;UNckwErBm(b3 Z1#ZCSIG({oSw(wO_y|6R`|ugm{siA7E-3&2 From 1061311d470ed9916cb35018f18d34e61a7a0094 Mon Sep 17 00:00:00 2001 From: Veronika Sanko Date: Thu, 23 Aug 2018 09:49:47 +0200 Subject: [PATCH 6/8] Add dexter-jenkins scr folder, remove bin folder and .project files --- .../dexter-jenkins/dexter-jenkins/.project | 15 - .../dexter-jenkins/bin/.project | 15 - .../plugins/dexter/DexterBuildAction.class | Bin 2577 -> 0 bytes .../plugins/dexter/DexterProjectAction.class | Bin 3049 -> 0 bytes .../plugins/dexter/DexterPublisher.class | Bin 9154 -> 0 bytes .../{dexter-jenkins/bin => }/pom.xml | 0 .../plugins/dexter/DexterBuildAction.java | 43 ++ .../plugins/dexter/DexterProjectAction.java | 56 +++ .../plugins/dexter/DexterPublisher.java | 422 ++++++++++++++++++ .../bin => }/src/main/resources/index.jelly | 0 .../dexter/DexterBuildAction/index.jelly | 0 .../dexter/DexterProjectAction/index.jelly | 0 .../dexter/DexterPublisher/config.jelly | 0 .../dexter/DexterPublisher/global.jelly | 0 14 files changed, 521 insertions(+), 30 deletions(-) delete mode 100644 project/dexter-jenkins/dexter-jenkins/.project delete mode 100644 project/dexter-jenkins/dexter-jenkins/bin/.project delete mode 100644 project/dexter-jenkins/dexter-jenkins/bin/src/main/java/io/jenkins/plugins/dexter/DexterBuildAction.class delete mode 100644 project/dexter-jenkins/dexter-jenkins/bin/src/main/java/io/jenkins/plugins/dexter/DexterProjectAction.class delete mode 100644 project/dexter-jenkins/dexter-jenkins/bin/src/main/java/io/jenkins/plugins/dexter/DexterPublisher.class rename project/dexter-jenkins/{dexter-jenkins/bin => }/pom.xml (100%) create mode 100644 project/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterBuildAction.java create mode 100644 project/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterProjectAction.java create mode 100644 project/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterPublisher.java rename project/dexter-jenkins/{dexter-jenkins/bin => }/src/main/resources/index.jelly (100%) rename project/dexter-jenkins/{dexter-jenkins/bin => }/src/main/resources/io/jenkins/plugins/dexter/DexterBuildAction/index.jelly (100%) rename project/dexter-jenkins/{dexter-jenkins/bin => }/src/main/resources/io/jenkins/plugins/dexter/DexterProjectAction/index.jelly (100%) rename project/dexter-jenkins/{dexter-jenkins/bin => }/src/main/resources/io/jenkins/plugins/dexter/DexterPublisher/config.jelly (100%) rename project/dexter-jenkins/{dexter-jenkins/bin => }/src/main/resources/io/jenkins/plugins/dexter/DexterPublisher/global.jelly (100%) diff --git a/project/dexter-jenkins/dexter-jenkins/.project b/project/dexter-jenkins/dexter-jenkins/.project deleted file mode 100644 index 3bfb0d74..00000000 --- a/project/dexter-jenkins/dexter-jenkins/.project +++ /dev/null @@ -1,15 +0,0 @@ - - - dexter-jenkins - Dexter plugin enables static analysis of the project as a Jenkins build step. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - - - org.eclipse.jdt.core.javabuilder - - - - org.eclipse.jdt.core.javanature - org.eclipse.jdt.groovy.core.groovyNature - - \ No newline at end of file diff --git a/project/dexter-jenkins/dexter-jenkins/bin/.project b/project/dexter-jenkins/dexter-jenkins/bin/.project deleted file mode 100644 index 3bfb0d74..00000000 --- a/project/dexter-jenkins/dexter-jenkins/bin/.project +++ /dev/null @@ -1,15 +0,0 @@ - - - dexter-jenkins - Dexter plugin enables static analysis of the project as a Jenkins build step. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - - - org.eclipse.jdt.core.javabuilder - - - - org.eclipse.jdt.core.javanature - org.eclipse.jdt.groovy.core.groovyNature - - \ No newline at end of file diff --git a/project/dexter-jenkins/dexter-jenkins/bin/src/main/java/io/jenkins/plugins/dexter/DexterBuildAction.class b/project/dexter-jenkins/dexter-jenkins/bin/src/main/java/io/jenkins/plugins/dexter/DexterBuildAction.class deleted file mode 100644 index 3580e8249f450ad75c21e0f88291cd31aa43e398..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2577 zcmbtWX>SuT5FNLrIViLg%2AG*awP>e9OXtx8ZIl#6yIvpjJoEf!oL|4c{Q!VPcvyfD0*{RLYY`K&w!u2ACRA;M%S|Co zEe?~GYXkn-a$S3wHqR3g21~vbN)}*@z*K4#GTExVYi@Ag5-3F67}nwhij5Vkg={?` zaH#1F2~0MYn#OA8+Y||BN-LrznN2hr9Pgcdy0GvJS4_6Jt@}#879oGjB3xIlRCl4z zzE7kT5wFXRFrpdqB`K9<&P9Vu8}B+?YY}in8hfDvUVvkWx$E~Ut(7jqaRTy#)ZD1B z!vpH8C>CLgLSwBEHZqTCxwMT&ede~IO-^@gtfGwCt(ccfS>XK_m0=2ICg3ETA~60` zNMWB5n5i^&UF*_UU30_<$=@bXlj~K6-Vm5>D4&IEObgfV4vyKjz^I=z4t%Ug(@`Y+ zr7&^Gwz_=dzy}@fc9ydvE&?SG4#3(VbPU8<=3J_sj0^&!m1?~RmkBKQcf_4ukNEnZ z4$2p!PIn@33U(vq z2sg>-tpU7WZSz#=)QQz|`R`@y`>bg$#to5)p1;%B*wErH_fWu2qEnPYKQi z)bm4T3|+@mH|0{!F8eC!|8@yDZtNV0nZJp}i_Qz>bt|FQt%P1y3Fm2`xS=ljBWC?J zwa5kk9AjjE+hYQHuC971L;Is;QHm&5+R}Cs7$tK!9CTGynsWf?ki}^j&6Vm=9134p zYLb|1tew(Wo%mL1nyI2vbpl9az}K;i1s+{ajCG`?W+(_DJ8F|thOD-G5eBQJL%F-J zhW;jLi2TG`W<@31=kA6gaB|O8nQ8zlMqN5;gt1)OH-c-X{q|M??hrWAvt0oe@k-df zX7A&7<}!haWnm0nsjGO)7`O;n{_rv%!QUYmPrnLK#L-gvU4{aFABG8>KY}CU*gJ~t zBtDC1Nw6({hpCU#(_i7lPwb7rX?(kNfOco_J&~<~SvZS50_P5hHkFHZ{(xvRxo8(s zZ}&zwmlNG=F2Y5a#~Ak_T*^V1%SE^XSCPex|7$r&l^mq`93;R$1`9h#*LRTId1q&K fBL|7(AdP~DHX~4jTi60Tz^4pja2xKzJsAB1OiRI< diff --git a/project/dexter-jenkins/dexter-jenkins/bin/src/main/java/io/jenkins/plugins/dexter/DexterProjectAction.class b/project/dexter-jenkins/dexter-jenkins/bin/src/main/java/io/jenkins/plugins/dexter/DexterProjectAction.class deleted file mode 100644 index 92ee371d943b83ea7f13e341737abf89a31226b0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3049 zcmcImTXP#V6h3m(+Fnf3rYXHr)Bq(8u%=L2N1Gk3!ndQ3kC|iEkYL^FgJ+MN_I?NC_pYcUZ4mwZz?v6k`$*Blj z=&kpS)hw_D;|hW1rWifs#Lph(BgAQZ6jDdk2y>trl{C zgx7ybr4=#n%8@XlAMtf5m1RylL%{1j8F8&e$dPpBp$d5&<`De==m)KpZomZs@~PC^ zsA$AP8mKrCQHDa%7KDw>x72G+&}hJ%7~1D_pT{c7s2wNVYv$S=PvpTYTx`JtTq1C8 zRY+mi&>c(DHnz7>;hvEEaT@oz-eRZ?f%%>aShUTwaQotL#tsEq{ax=3Vv3HMMdv>f zCW+WM_q~S)Pjz&#DS}DhB1UC8!k4E{v$!^Z68OD>pASJE@5$z=sB`lQ1Dr(-_>e$a zL8&THJ*_VD=-EP-4Q>n@aExCA-PaSwVkmADpR3dFVr``XOQd$Eg60nF1Rqv1?rq_$ zYt6=Q3#|Dr6`$c8zF^rF4gDE(0vUJ6grK z|1HJ4korO9!5wS{#%nquA;%+km9StBvxY7TQo)>zcMi8NlKu#A&kL+W(&s$1Gj*{8643F)Zi?f!?ljP8Z>al@d-Tq zeg{w7O$*m|@pl(F2(I2=F#GHL`9EO(Iqquk9{xKzfH}B~|E-(~uE15?5xDl6XbYui z*IyIuYAMa#R?a%XM{tk=p@>tHdqfSG~kljm} zm|w}nMrSMHvdM%?6Aqos#zcPHm|x$z!-CYI$v`kaWi=+YnQ+Lt?NGVxr%gTFp_yub zOf3~WZY(%7-4=-&zS@bR4JbQQl1WDdY=r~k*cOkohf*G?u4Jn`V%Pl^ zb7-QDM`+iR2ucpQ2GpUVjQzH3CdxeRP1n4#Zf+z3eWr0!s?jG*k1yp;B0^ZCyx2^Z ze5DB$xVOS(&>N;3CkOGhE1CPtNnGa*hmISgw8`Dp=58C7yDcWA-@sF0y@p81EIdn{ zdYy^&`ih_WFsrJArr#oTMdfvz1)!j;DOGEMAID6fZ>qskWkYxJ)3bB7=ua#sA#-UK z>(F1DD?%iqNEaMhy%`H8lW3cTUXZlfJn~bX#2!4^idgFzuUyhLd1~S$^|qMT8;~ZR z@1=0BT&BnA$w~S=Rj@{vc+Atw4m~)#*PyvuFr><3cD>WuVq(+BEGlo3z>jYEf~&T9 zIgvKGbm-~oeI_wt^sm|5drkN-zPXKmDs<;=bmEk^*jl{JB}c3l)uLoehEScUsytds zI&p}sK!$aKG!Y9$ddivp_rVJ-)k<$RS+<;>%9M(#{K{riBs*$REbCwK)>4m4kH;Yw zDDY?(seyE6ae!>9i=>72s~z-(UL}Z7Y@W(zsV527_7~-D_jc!STqGirVZdnfd#p>G^r9jg3LO$`gxw9~!mM);Bw$ zL{aZ8;UOOnQ!877PRgSXa?-A|a9Cr)lDuC3C^FW0T3m**SgeSLbteFZ5Q1c?Eqxkjgcs(&AErBhae)nprNbfeOQe;r>co z8VK-nT-JL0pNoNdnrS@gy{AhCD!R<C~atFxVrNtfDSoDU~b zNQL3hxdaAuYABIi>R>nPzA|xeX$Ks&4uwlFacU^XU3v`xeQ%Im`XSP@TNW<8j#l?N z>e5e8O@^3v=?yrocWHg%aOr15zoqCtC|%R1ANBKqq=(6&2k^_yIV#Y{=op>~f2iL+c{Ebs)=srN>{MnR}a_cn7Tl z&Ex-LS-j z2&@Q~=-B~;LeB;pLc@x1IY&(HS`ogU10k^>l;|5hgbP^~b|Yz97nva_PaRt9jT^n5 zJC>OpTFQa&niXL=2g2)Cgq0i!Z&(qoa!=J1O8#!$F zvlZcm90+e)5K45T=f&uq>2Dc=+L=mJ>*ezBxJ}E>{%&uaL$~O~f$z&p!0LV-CVG4O z%NC4(Sga>{g}yazCOMB-5DN5d`py7C{|oiqy*4<{S`qvl2rpO>wsIiUEeH+;6z&t% zzDJg*I`;jVQT@Kq-n81*peDX~9IIQPJH3;|;L7*E>NXpHVL_dsyBS_YEl8pme`Ty= fg1=YkEd3nqGk7B?rER)L-=`nYkLbtrQ+o5im=UNf diff --git a/project/dexter-jenkins/dexter-jenkins/bin/pom.xml b/project/dexter-jenkins/pom.xml similarity index 100% rename from project/dexter-jenkins/dexter-jenkins/bin/pom.xml rename to project/dexter-jenkins/pom.xml diff --git a/project/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterBuildAction.java b/project/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterBuildAction.java new file mode 100644 index 00000000..c7bfe4ee --- /dev/null +++ b/project/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterBuildAction.java @@ -0,0 +1,43 @@ +package io.jenkins.plugins.dexter; +import hudson.model.AbstractBuild; +import hudson.model.Action; + + +public class DexterBuildAction implements Action { + + private String message; + private AbstractBuild build; + + @Override + public String getIconFileName() { + return "/plugin/testExample/img/build-goals.png"; + } + + @Override + public String getDisplayName() { + return "Static analysis results"; + } + + @Override + public String getUrlName() { + return "analysisResults"; + } + + public String getMessage() { + return this.message; + } + + public int getBuildNumber() { + return this.build.number; + } + + public AbstractBuild getBuild() { + return build; + } + + DexterBuildAction(final String message, final AbstractBuild build) + { + this.message = message; + this.build = build; + } +} diff --git a/project/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterProjectAction.java b/project/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterProjectAction.java new file mode 100644 index 00000000..002ff72a --- /dev/null +++ b/project/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterProjectAction.java @@ -0,0 +1,56 @@ +package io.jenkins.plugins.dexter; + +import hudson.model.AbstractBuild; +import hudson.model.AbstractProject; +import hudson.model.Action; + +import java.util.ArrayList; +import java.util.List; + + +public class DexterProjectAction implements Action { + + private AbstractProject project; + + @Override + public String getIconFileName() { + return "/plugin/testExample/img/project_icon.png"; + } + + @Override + public String getDisplayName() { + return ""; + } + + @Override + public String getUrlName() { + return "dexterAnalysis"; + } + + public AbstractProject getProject() { + return this.project; + } + + public String getProjectName() { + return this.project.getName(); + } + + public List getProjectMessages() { + List projectMessages = new ArrayList(); + List> builds = project.getBuilds(); + String projectMessage=""; + final Class buildClass =DexterBuildAction.class; + + for (AbstractBuild currentBuild : builds) { + int buildNumber = currentBuild.getAction(buildClass).getBuildNumber(); + String message = currentBuild.getAction(buildClass).getMessage(); + projectMessage = String.format("Build # %1$s : %2$s ", buildNumber, message); + projectMessages.add(projectMessage); + } + return projectMessages; + } + + DexterProjectAction(final AbstractProject project) { + this.project = project; + } +} diff --git a/project/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterPublisher.java b/project/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterPublisher.java new file mode 100644 index 00000000..ff16c696 --- /dev/null +++ b/project/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterPublisher.java @@ -0,0 +1,422 @@ +package io.jenkins.plugins.dexter; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStreamReader; + +import io.jenkins.plugins.dexter.*; +import hudson.Launcher; +import hudson.Extension; +import hudson.model.Action; +import java.util.logging.ConsoleHandler; +import hudson.tasks.*; +import hudson.util.FormValidation; +import hudson.model.AbstractBuild; +import hudson.model.BuildListener; +import hudson.model.AbstractProject; +import net.sf.json.JSONObject; +import org.kohsuke.stapler.DataBoundConstructor; +import org.kohsuke.stapler.StaplerRequest; +import org.kohsuke.stapler.QueryParameter; + +import javax.servlet.ServletException; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.OpenOption; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; +import java.util.Scanner; + +public class DexterPublisher extends Recorder { + + private boolean createServer; + private String pathDexter; + private String projectFullPath; + private String sourceDir; + private String binDir; + private String headerDir; + private final String analyseFileName; + private final boolean file; + private final boolean folder; + private final boolean project; + private final boolean snapshot; + private String dexterServer; + private String dexterPort; + private String dexterUser; + private String dexterPassword; + private String pathToBat = ""; + private String serverDisc = ""; + private String dexterDisc = ""; + private String dexterServerPath = ""; + private String pathConfig = ""; + private String projectName = ""; + private String projectType = ""; + String message; + + public String getPathConfig() { + return pathConfig; + } + + // Fields in config.jelly must match the parameter names in the + // "DataBoundConstructor" + @DataBoundConstructor + public DexterPublisher(boolean createServer, String dexterServerPath, String dexterServer, String dexterPort, + String dexterUser, String dexterPassword, String pathDexter, String projectFullPath, String sourceDir, + String binDir, String headerDir, String analyseFileName, boolean file, boolean folder, boolean project, + boolean snapshot) { + this.createServer = createServer; + this.dexterServerPath = dexterServerPath; + this.dexterServer = dexterServer; + this.dexterPort = dexterPort; + this.dexterUser = dexterUser; + this.dexterPassword = dexterPassword; + this.pathDexter = pathDexter; + this.projectFullPath = projectFullPath; + this.sourceDir = sourceDir; + this.binDir = binDir; + this.headerDir = headerDir; + this.analyseFileName = analyseFileName; + this.file = file; + this.folder = folder; + this.project = project; + this.snapshot = snapshot; + } + + public boolean isCreateServer() { + return createServer; + } + + public void setCreateServer(boolean createServer) { + this.createServer = createServer; + } + + public String getAnalyseFileName() { + return analyseFileName; + } + + public String getHeaderDir() { + return headerDir; + } + + public static String getFilename() { + return filename; + } + + public String getProjectName() { + return "project"; + } + + public String getProjectFullPath() { + return projectFullPath; + } + + public String getSourceDir() { + return sourceDir; + } + + public String getBinDir() { + return binDir; + } + + public boolean isFile() { + return file; + } + + public boolean isFolder() { + return folder; + } + + public boolean isProject() { + return project; + } + + public boolean isSnapshot() { + return snapshot; + } + + public String getName() { + return pathDexter; + } + + public String getDexterServer() { + return dexterServer; + } + + public String getDexterPort() { + return dexterPort; + } + + public void setDexterPort(String dexterPort) { + this.dexterPort = dexterPort; + } + + public String getDexterUser() { + return dexterUser; + } + + public void setDexterUser(String dexterUser) { + this.dexterUser = dexterUser; + } + + public String getDexterPassword() { + return dexterPassword; + } + + public void setDexterPassword(String dexterPassword) { + this.dexterPassword = dexterPassword; + } + + public void setDexterServer(String dexterServer) { + this.dexterServer = dexterServer; + } + + private static String OS = null; + + public static String getOsName() { + if (OS == null) { + OS = System.getProperty("os.name"); + } + return OS; + } + + public static boolean isWindows() { + return getOsName().startsWith("Windows"); + } + + @Override + public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) { + pathToBat = pathDexter + "/bin"; + pathConfig = pathDexter + "/bin/dexter_cfg.json"; + projectName = getProjectName(); + serverDisc = dexterServerPath.substring(0, 2); + dexterDisc = pathDexter.substring(0, 2); + if (file) { + projectType = "FILE"; + } + if (folder) { + projectType = "FOLDER"; + } + if (project) { + projectType = "PROJECT"; + } + if (snapshot) { + projectType = "SNAPSHOT"; + } + + if (isCreateServer()) { + if (isWindows()) { + writeToBatFile(); + Runtime runtime = Runtime.getRuntime(); + String command = "cmd /c start /wait cmd.exe /K " + "\"cd " + dexterServerPath + " && " + serverDisc + + " && run.bat \""; + try { + runtime.exec(command); + } catch (IOException e) { + e.printStackTrace(); + } + + writeToFile(); + + String commandDexter = "cmd /c start cmd.exe /K " + "\"cd " + pathToBat + " && " + dexterDisc + + " && dexter.bat " + dexterUser + " " + dexterPassword + " > logs.txt \""; + try { + runtime.exec(commandDexter); + } catch (IOException e) { + e.printStackTrace(); + } + + if (readFile(pathToBat + "//logs.txt")) { + message = stringBufferOfData.toString(); + } else + message = "Error saving logs"; + } else { + + writeToShFile(); + writeToFile(); + + try { + message = ""; + int ch; + + ProcessBuilder pb = new ProcessBuilder(dexterServerPath + "/run.sh"); + pb.directory(new File(dexterServerPath)); + + Process shellProcess = pb.start(); + + ProcessBuilder pbClient = new ProcessBuilder(pathToBat + "/dexter.sh", dexterUser, dexterPassword); + pbClient.directory(new File(pathToBat)); + + Process shellProcessClient = pbClient.start(); + + InputStreamReader myIStreamReader = new InputStreamReader(shellProcessClient.getInputStream()); + + while ((ch = myIStreamReader.read()) != -1) { + System.out.print((char) ch); + char temp = (char) ch; + message = message + Character.toString(temp); + shellProcess.destroy(); + } + } catch (IOException anIOException) { + System.out.println(anIOException); + } catch (Exception e) { + e.printStackTrace(); + + } + } + } + + DexterBuildAction buildAction = new DexterBuildAction(message, build); + build.addAction(buildAction); + return true; + } + + static StringBuffer stringBufferOfData = new StringBuffer(); + static String filename = null; + static Scanner sc = new Scanner(System.in, "UTF-8"); + + private boolean readFile(String filenameRead) { + filename = filenameRead; + Scanner fileToRead = null; + try { + stringBufferOfData.replace(0, stringBufferOfData.length(), " "); + fileToRead = new Scanner(new File(filename), "UTF-8"); + for (String line; fileToRead.hasNextLine() && (line = fileToRead.nextLine()) != null;) { + System.out.println(line); + stringBufferOfData.append(line).append("\n"); + } + fileToRead.close(); + return true; + } catch (FileNotFoundException ex) { + System.out.println("The file " + filename + " could not be found! " + ex.getMessage()); + return false; + } finally { + if (fileToRead != null) { + fileToRead.close(); + } + return true; + } + + } + + private void writeToBatFile() { + + OpenOption myOpt = StandardOpenOption.CREATE; + try { + Path fileToWrite = Paths.get(dexterServerPath + "/run.bat"); + BufferedWriter bufwriter = Files.newBufferedWriter(fileToWrite, Charset.forName("UTF-8"), myOpt); + bufwriter.write("node server.js -database.host="); + bufwriter.write(dexterServer); + bufwriter.write(" -p="); + bufwriter.write(dexterPort); + bufwriter.write(" -database.name=my_dexter_db -database.user="); + bufwriter.write(dexterUser); + bufwriter.write(" -database.password="); + bufwriter.write(dexterPassword); + bufwriter.close(); + } catch (Exception e) { + System.out.println("Error occured while attempting to write to file: " + e.getMessage()); + } + } + + private void writeToShFile() { + + OpenOption myOpt = StandardOpenOption.CREATE; + try { + Path fileToWrite = Paths.get(dexterServerPath + "/run.sh"); + + BufferedWriter bufwriter = Files.newBufferedWriter(fileToWrite, Charset.forName("UTF-8"), myOpt); + bufwriter.write("node server.js -database.host="); + bufwriter.write(dexterServer); + bufwriter.write(" -p="); + bufwriter.write(dexterPort); + bufwriter.write(" -database.name=my_dexter_db -database.user="); + bufwriter.write(dexterUser); + bufwriter.write(" -database.password="); + bufwriter.write(dexterPassword); + bufwriter.close(); + } catch (Exception e) { + System.out.println("Error occured while attempting to write to file: " + e.getMessage()); + } + } + + private void writeToFile() { + + OpenOption myOpt = StandardOpenOption.CREATE; + try { + Path fileToWrite = Paths.get(pathConfig); + BufferedWriter bufwriter = Files.newBufferedWriter(fileToWrite, Charset.forName("UTF-8"), myOpt); + bufwriter.write("{\n"); + bufwriter.write("\"dexterHome\":\"" + pathDexter + "\", \n"); + bufwriter.write("\"dexterServerIp\":\"" + dexterServer + "\", \n"); + bufwriter.write("\"dexterServerPort\":\"" + dexterPort + "\", \n"); + bufwriter.write("\"projectName\":\"" + projectName + "\", \n"); + bufwriter.write("\"projectFullPath\":\"" + projectFullPath + "\", \n"); + bufwriter.write("\"sourceDir\":[\"" + sourceDir + "\"], \n"); + bufwriter.write("\"headerDir\":[\"" + headerDir + "\"], \n"); + bufwriter.write("\"sourceEncoding\":\"UTF-8\", \n"); + bufwriter.write("\"libDir\":[], \n"); + bufwriter.write("\"binDir\":\"\", \n"); + bufwriter.write("\"modulePath\":\"\", \n"); + bufwriter.write("\"fileName\":[\"" + analyseFileName + "\"], \n"); + bufwriter.write("\"type\":\"" + projectType + "\" \n"); + bufwriter.write("}\n"); + bufwriter.close(); + } catch (Exception e) { + System.out.println("Error occured while attempting to write to file: " + e.getMessage()); + } + } + + @Override + public DescriptorImpl getDescriptor() { + return (DescriptorImpl) super.getDescriptor(); + } + + @Override + public BuildStepMonitor getRequiredMonitorService() { + return BuildStepMonitor.NONE; + } + + @Override + public Action getProjectAction(AbstractProject project) { + return new DexterProjectAction(project); + } + + @Extension + public static final class DescriptorImpl extends BuildStepDescriptor { + + public DescriptorImpl() { + load(); + } + + public boolean isApplicable(Class aClass) { + + return true; + } + + public String getDisplayName() { + return "Dexter Static Analysis"; + } + + @Override + public boolean configure(StaplerRequest req, JSONObject formData) throws FormException { + + save(); + return super.configure(req, formData); + } + + } +} \ No newline at end of file diff --git a/project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/index.jelly b/project/dexter-jenkins/src/main/resources/index.jelly similarity index 100% rename from project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/index.jelly rename to project/dexter-jenkins/src/main/resources/index.jelly diff --git a/project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/io/jenkins/plugins/dexter/DexterBuildAction/index.jelly b/project/dexter-jenkins/src/main/resources/io/jenkins/plugins/dexter/DexterBuildAction/index.jelly similarity index 100% rename from project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/io/jenkins/plugins/dexter/DexterBuildAction/index.jelly rename to project/dexter-jenkins/src/main/resources/io/jenkins/plugins/dexter/DexterBuildAction/index.jelly diff --git a/project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/io/jenkins/plugins/dexter/DexterProjectAction/index.jelly b/project/dexter-jenkins/src/main/resources/io/jenkins/plugins/dexter/DexterProjectAction/index.jelly similarity index 100% rename from project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/io/jenkins/plugins/dexter/DexterProjectAction/index.jelly rename to project/dexter-jenkins/src/main/resources/io/jenkins/plugins/dexter/DexterProjectAction/index.jelly diff --git a/project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/io/jenkins/plugins/dexter/DexterPublisher/config.jelly b/project/dexter-jenkins/src/main/resources/io/jenkins/plugins/dexter/DexterPublisher/config.jelly similarity index 100% rename from project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/io/jenkins/plugins/dexter/DexterPublisher/config.jelly rename to project/dexter-jenkins/src/main/resources/io/jenkins/plugins/dexter/DexterPublisher/config.jelly diff --git a/project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/io/jenkins/plugins/dexter/DexterPublisher/global.jelly b/project/dexter-jenkins/src/main/resources/io/jenkins/plugins/dexter/DexterPublisher/global.jelly similarity index 100% rename from project/dexter-jenkins/dexter-jenkins/bin/src/main/resources/io/jenkins/plugins/dexter/DexterPublisher/global.jelly rename to project/dexter-jenkins/src/main/resources/io/jenkins/plugins/dexter/DexterPublisher/global.jelly From 3c4d52cfcb2919d0c56b8c1a83ea3e3ef2444cd1 Mon Sep 17 00:00:00 2001 From: Veronika Sanko Date: Thu, 23 Aug 2018 10:09:50 +0200 Subject: [PATCH 7/8] Remove destroing process from loop --- .../main/java/io/jenkins/plugins/dexter/DexterPublisher.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterPublisher.java b/project/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterPublisher.java index ff16c696..115af712 100644 --- a/project/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterPublisher.java +++ b/project/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterPublisher.java @@ -268,8 +268,8 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListener lis System.out.print((char) ch); char temp = (char) ch; message = message + Character.toString(temp); - shellProcess.destroy(); } + shellProcess.destroy(); } catch (IOException anIOException) { System.out.println(anIOException); } catch (Exception e) { From e8cbc39b491dc62cee18488bfe00445f717d859d Mon Sep 17 00:00:00 2001 From: Veronika Sanko Date: Fri, 24 Aug 2018 12:58:10 +0200 Subject: [PATCH 8/8] Change input stream reading --- .../java/io/jenkins/plugins/dexter/DexterPublisher.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/project/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterPublisher.java b/project/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterPublisher.java index 115af712..3327b8f8 100644 --- a/project/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterPublisher.java +++ b/project/dexter-jenkins/src/main/java/io/jenkins/plugins/dexter/DexterPublisher.java @@ -5,6 +5,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; +import org.apache.commons.io.IOUtils; import io.jenkins.plugins.dexter.*; import hudson.Launcher; @@ -264,11 +265,8 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListener lis InputStreamReader myIStreamReader = new InputStreamReader(shellProcessClient.getInputStream()); - while ((ch = myIStreamReader.read()) != -1) { - System.out.print((char) ch); - char temp = (char) ch; - message = message + Character.toString(temp); - } + String result = IOUtils.toString(shellProcessClient.getInputStream(), StandardCharsets.UTF_8); + message = result; shellProcess.destroy(); } catch (IOException anIOException) { System.out.println(anIOException);