From 744be9d1da7b33568f5314130a9ffbd562271e16 Mon Sep 17 00:00:00 2001 From: Oleg Nenashev Date: Thu, 26 Mar 2020 23:56:15 +0100 Subject: [PATCH] [JENKINS-61694] - Update Groovy Init hooks to run after all job configurations are adapted --- core/src/main/java/hudson/init/InitMilestone.java | 7 ++++--- core/src/main/java/hudson/init/impl/GroovyInitScript.java | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/hudson/init/InitMilestone.java b/core/src/main/java/hudson/init/InitMilestone.java index 2653857f4d..4ee9fa26f4 100644 --- a/core/src/main/java/hudson/init/InitMilestone.java +++ b/core/src/main/java/hudson/init/InitMilestone.java @@ -106,14 +106,15 @@ public enum InitMilestone implements Milestone { JOB_LOADED("Loaded all jobs"), /** - * By this milestone, any job configuration is adapted or updated just in case any plugin needs to update former/old configurations or init scripts + * By this milestone, any job configuration is adapted or updated just in case any plugin needs to update former/old configurations. + * It does not include {@link hudson.init.impl.GroovyInitScript}s which get executed later * @since 2.220 */ JOB_CONFIG_ADAPTED("Configuration for all jobs updated"), /** - * The very last milestone - * + * The very last milestone. + * All executions should be completed by it, including {@link hudson.init.impl.GroovyInitScript}s. * This is used in {@link Initializer#before()} since annotations cannot have null as the default value. */ COMPLETED("Completed initialization"); diff --git a/core/src/main/java/hudson/init/impl/GroovyInitScript.java b/core/src/main/java/hudson/init/impl/GroovyInitScript.java index 20cd1a481c..b0ec56ddf3 100644 --- a/core/src/main/java/hudson/init/impl/GroovyInitScript.java +++ b/core/src/main/java/hudson/init/impl/GroovyInitScript.java @@ -32,11 +32,12 @@ import static hudson.init.InitMilestone.*; /** * Run the initialization script, if it exists. + * It runs strictly after the initialization of other tasks during the last initialization milestone. * * @author Kohsuke Kawaguchi */ public class GroovyInitScript { - @Initializer(after=JOB_LOADED) + @Initializer(after=JOB_CONFIG_ADAPTED) public static void init(Jenkins j) { new GroovyHookScript("init", j.servletContext, j.getRootDir(), j.getPluginManager().uberClassLoader).run(); } -- GitLab