Skip to content

Commit

Permalink
Opens probe execution filtering implementation (#575)
Browse files Browse the repository at this point in the history
  • Loading branch information
alecharp authored Dec 17, 2024
1 parent cba2a79 commit 21771f8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions docs/ARCHITECTURE.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 21771f8

Please sign in to comment.