Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JENKINS-26828 Add support for installing the NodeJS windows msi
Remove unused old method. Update some old duplicate code from jenkins core code. Extend version with range capabilities to check which version has only an msi installer.
- Loading branch information
Showing
10 changed files
with
2,084 additions
and
449 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package jenkins.plugins.nodejs.tools; | ||
|
||
import java.io.IOException; | ||
import java.util.Locale; | ||
import java.util.Map; | ||
|
||
import hudson.model.Node; | ||
|
||
/** | ||
* CPU type. | ||
*/ | ||
public enum CPU { | ||
i386, amd64; | ||
|
||
/** | ||
* Determines the CPU of the given node. | ||
* @throws IOException | ||
* @throws InterruptedException | ||
* @throws DetectionFailedException | ||
*/ | ||
public static CPU of(Node node) throws DetectionFailedException, InterruptedException, IOException { | ||
return detect(node.toComputer().getSystemProperties()); | ||
} | ||
|
||
/** | ||
* Determines the CPU of the current JVM. | ||
* @throws DetectionFailedException | ||
*/ | ||
public static CPU current() throws DetectionFailedException { | ||
return detect(System.getProperties()); | ||
} | ||
|
||
private static CPU detect(Map<Object, Object> systemProperties) throws DetectionFailedException { | ||
String arch = ((String) systemProperties.get("os.arch")).toLowerCase(Locale.ENGLISH); | ||
if (arch.contains("amd64") || arch.contains("86_64")) { | ||
return amd64; | ||
} | ||
if (arch.contains("86")) { | ||
return i386; | ||
} | ||
throw new DetectionFailedException("Unknown CPU architecture: " + arch); | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/jenkins/plugins/nodejs/tools/DetectionFailedException.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,17 @@ | ||
package jenkins.plugins.nodejs.tools; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Indicates the failure to detect the OS or CPU. | ||
*/ | ||
@SuppressWarnings("serial") | ||
public final class DetectionFailedException extends IOException { | ||
DetectionFailedException(String message) { | ||
super(message); | ||
} | ||
|
||
public DetectionFailedException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
} |
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.