diff --git a/core/src/main/java/io/jenkins/pluginhealth/scoring/probes/Probe.java b/core/src/main/java/io/jenkins/pluginhealth/scoring/probes/Probe.java index 74929256a..ec8e68290 100644 --- a/core/src/main/java/io/jenkins/pluginhealth/scoring/probes/Probe.java +++ b/core/src/main/java/io/jenkins/pluginhealth/scoring/probes/Probe.java @@ -48,7 +48,7 @@ public abstract class Probe { * @return the result of the analyze in a {@link ProbeResult} */ public final ProbeResult apply(Plugin plugin, ProbeContext context) { - if (shouldBeExecuted(plugin, context)) { + if (isApplicable(plugin, context)) { if (LOGGER.isTraceEnabled()) { LOGGER.trace("Running {} on {}", this.key(), plugin.getName()); } @@ -58,7 +58,14 @@ public final ProbeResult apply(Plugin plugin, ProbeContext context) { return lastResult != null ? lastResult : this.error(key() + " was not executed on " + plugin.getName()); } - private boolean shouldBeExecuted(Plugin plugin, ProbeContext context) { + /** + * Determine if the current probe should or should not be applied to the plugin with its context. + * + * @param plugin the plugin to apply the probe to + * @param context the built context to run the probe with + * @return true if the probe have to be applied to the plugin + */ + protected boolean isApplicable(Plugin plugin, ProbeContext context) { final ProbeResult previousResult = plugin.getDetails().get(this.key()); if (previousResult == null) { return true; diff --git a/docs/ARCHITECTURE.adoc b/docs/ARCHITECTURE.adoc index 6c656d74c..47600f040 100644 --- a/docs/ARCHITECTURE.adoc +++ b/docs/ARCHITECTURE.adoc @@ -40,6 +40,8 @@ There are conditions for each probe to be executed: - if the last execution of the probe on a specific plugin was done before the last code change of the plugin and the probe is based on the code of the plugin - if the last execution of the probe on a specific plugin was done before the last release of the plugin and the probe requires a release to have its result changed +Each probe can override the method `Probe#isApplicable(Plugin, ProbeContext)` to use other data and decide if it should be executed or no by the `ProbeEngine`. + The `ProbeEngine` is scheduled by the link:../war/src/main/java/io/jenkins/pluginhealth/scoring/schedule/ProbeEngineScheduler.java[`ProbeEngineScheduler`] class. This is using a CRON expression for its scheduling. The environment variable `PROBE_ENGINE_CRON` is used to configure this CRON.