diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/DetectVMInstallationsJob.java b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/DetectVMInstallationsJob.java
index 7a0b9c15e3..0373047b08 100644
--- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/DetectVMInstallationsJob.java
+++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/DetectVMInstallationsJob.java
@@ -46,6 +46,20 @@
*/
public class DetectVMInstallationsJob extends Job {
+ /**
+ * CI is a common variable defined in CI/CDI servers like Jenkins, Gitlab, Github, ... to indicate it is a CI environment
+ */
+ private static final String ENV_CI = "CI"; //$NON-NLS-1$
+ /**
+ * Property that can be defined to control general behavior
+ *
+ * DetectVMInstallationsJob.disabled = true - automatic discovery is always disabled
+ * DetectVMInstallationsJob.disabled = false - check runs everywhere depending on preferences
+ * DetectVMInstallationsJob.disabled not specified - automatic discovery is disabled if environment variable CI has
+ * value true otherwise runs depending on preferences
+ *
+ */
+ private static final String PROPERTY_DETECT_VM_INSTALLATIONS_JOB_DISABLED = "DetectVMInstallationsJob.disabled"; //$NON-NLS-1$
private static final Object FAMILY = DetectVMInstallationsJob.class;
public DetectVMInstallationsJob() {
@@ -222,11 +236,19 @@ public boolean belongsTo(Object family) {
}
public static void initialize() {
- boolean forcedDisableVMDetection = Boolean.getBoolean("DetectVMInstallationsJob.disabled"); //$NON-NLS-1$
+ if (Boolean.getBoolean(PROPERTY_DETECT_VM_INSTALLATIONS_JOB_DISABLED)) {
+ // early exit no need to read preferences or check env variable!
+ return;
+ }
+ if (System.getProperty(PROPERTY_DETECT_VM_INSTALLATIONS_JOB_DISABLED) == null && Boolean.parseBoolean(System.getenv(ENV_CI))) {
+ // exit because no explicit value for the property was given and we are running in a CI environment
+ return;
+ }
+ // finally look what is defined in the preferences
IEclipsePreferences instanceNode = InstanceScope.INSTANCE.getNode(LaunchingPlugin.getDefault().getBundle().getSymbolicName());
IEclipsePreferences defaultNode = DefaultScope.INSTANCE.getNode(LaunchingPlugin.getDefault().getBundle().getSymbolicName());
boolean defaultValue = defaultNode.getBoolean(LaunchingPlugin.PREF_DETECT_VMS_AT_STARTUP, true);
- if (!forcedDisableVMDetection && instanceNode.getBoolean(LaunchingPlugin.PREF_DETECT_VMS_AT_STARTUP, defaultValue)) {
+ if (instanceNode.getBoolean(LaunchingPlugin.PREF_DETECT_VMS_AT_STARTUP, defaultValue)) {
new DetectVMInstallationsJob().schedule();
}
}