Skip to content

Commit

Permalink
Merge pull request #180 from VeronikaSanko/master
Browse files Browse the repository at this point in the history
Linux bugs fixed
  • Loading branch information
KarolAntczak authored Aug 27, 2018
2 parents cfabed1 + e8cbc39 commit 8331f65
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 30 deletions.
15 changes: 0 additions & 15 deletions dexter-jenkins/dexter-jenkins/.project

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
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 org.apache.commons.io.IOUtils;

import io.jenkins.plugins.dexter.*;
import hudson.Launcher;
import hudson.Extension;
Expand Down Expand Up @@ -238,27 +245,35 @@ 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) {
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());

String result = IOUtils.toString(shellProcessClient.getInputStream(), StandardCharsets.UTF_8);
message = result;
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";
}
}
}

Expand Down Expand Up @@ -296,6 +311,7 @@ private boolean readFile(String filenameRead) {
}

private void writeToBatFile() {

OpenOption myOpt = StandardOpenOption.CREATE;
try {
Path fileToWrite = Paths.get(dexterServerPath + "/run.bat");
Expand All @@ -315,9 +331,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);
Expand All @@ -334,6 +352,7 @@ private void writeToShFile() {
}

private void writeToFile() {

OpenOption myOpt = StandardOpenOption.CREATE;
try {
Path fileToWrite = Paths.get(pathConfig);
Expand Down

0 comments on commit 8331f65

Please sign in to comment.