-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pipeline): Improved pipeline implementation to be pipeline-first
- Loading branch information
Showing
21 changed files
with
517 additions
and
666 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/main/java/com/synopsys/integration/jenkins/detect/JavaExecutableManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.synopsys.integration.jenkins.detect; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.Arrays; | ||
import java.util.Map; | ||
|
||
import org.apache.commons.io.IOUtils; | ||
import org.apache.commons.lang3.SystemUtils; | ||
|
||
import com.synopsys.integration.log.LogLevel; | ||
|
||
public class JavaExecutableManager { | ||
private final DetectJenkinsLogger logger; | ||
private final Map<String, String> environmentVariables; | ||
|
||
public JavaExecutableManager(final DetectJenkinsLogger logger, final Map<String, String> environmentVariables) { | ||
this.logger = logger; | ||
this.environmentVariables = environmentVariables; | ||
} | ||
|
||
public String calculateJavaExecutablePath(final String javaHome) throws IOException { | ||
String javaExecutablePath = "java"; | ||
if (javaHome != null) { | ||
File java = new File(javaHome); | ||
java = new File(java, "bin"); | ||
if (SystemUtils.IS_OS_WINDOWS) { | ||
java = new File(java, "java.exe"); | ||
} else { | ||
java = new File(java, "java"); | ||
} | ||
javaExecutablePath = java.getCanonicalPath(); | ||
} | ||
return javaExecutablePath; | ||
} | ||
|
||
public void logJavaVersion() { | ||
logger.debug("PATH: " + environmentVariables.get("PATH")); | ||
if (LogLevel.DEBUG == logger.getLogLevel()) { | ||
try { | ||
logger.info("Java version: "); | ||
final ProcessBuilder processBuilder = new ProcessBuilder(Arrays.asList("java", "-version")); | ||
processBuilder.environment().putAll(environmentVariables); | ||
final Process process = processBuilder.start(); | ||
process.waitFor(); | ||
IOUtils.copy(process.getErrorStream(), logger.getJenkinsListener().getLogger()); | ||
IOUtils.copy(process.getInputStream(), logger.getJenkinsListener().getLogger()); | ||
} catch (final InterruptedException | IOException e) { | ||
logger.debug("Error printing the JAVA version: " + e.getMessage(), e); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.