Created
September 23, 2016 06:37
-
-
Save msteiger/8c7ce6fd413b160a1e9642253fc472e7 to your computer and use it in GitHub Desktop.
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 gem executes a single JUnit test conditionally. If the machine name contains a sub-string | |
// such as "dev", it will always be successful | |
public class MyTests { | |
final static private String[] JenkinsServerNameParts = new String[] { "da-build", "master", "soap", "dev" }; | |
@Test | |
public void startNightVision() { | |
if(isRunOnJenkinsServer()) | |
return; | |
... | |
} | |
protected boolean isRunOnJenkinsServer() { | |
try { | |
String hostName = InetAddress.getLocalHost().getHostName().toLowerCase(); | |
for(String serverNamePart : JenkinsServerNameParts) { | |
if(hostName.contains(serverNamePart)) { | |
return true; | |
} | |
} | |
return false; | |
} | |
catch (UnknownHostException e) { | |
return false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment