From a9a43062e395f1edc6f685cdd5266fb89ac83efb Mon Sep 17 00:00:00 2001 From: Pashupati Kaushik Date: Mon, 27 Jun 2022 18:47:37 -0400 Subject: [PATCH] register perms at start up --- .../hudson/plugins/promoted_builds/Promotion.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/hudson/plugins/promoted_builds/Promotion.java b/src/main/java/hudson/plugins/promoted_builds/Promotion.java index af40188e..c9c0aad3 100644 --- a/src/main/java/hudson/plugins/promoted_builds/Promotion.java +++ b/src/main/java/hudson/plugins/promoted_builds/Promotion.java @@ -57,6 +57,10 @@ import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; +import hudson.init.InitMilestone; +import hudson.init.Initializer; +import org.kohsuke.accmod.restrictions.DoNotUse; + /** * Records a promotion process. * @@ -486,6 +490,16 @@ private boolean preBuild(BuildListener listener, List steps) { public static final PermissionGroup PERMISSIONS = new PermissionGroup(Promotion.class, Messages._Promotion_Permissions_Title()); public static final Permission PROMOTE = new Permission(PERMISSIONS, "Promote", Messages._Promotion_PromotePermission_Description(), Jenkins.ADMINISTER, PermissionScope.RUN); + @Initializer(before = InitMilestone.SYSTEM_CONFIG_LOADED) + @Restricted(DoNotUse.class) + public static void registerPermissions() { + // Pending JENKINS-17200, ensure that the above permissions have been registered prior to + // allowing plugins to adapt the system configuration, which may depend on these permissions + // having been registered. Since this method is static and since it follows the above + // construction of static permission objects (and therefore their calls to + // PermissionGroup#register), there is nothing further to do in this method. + } + @Override public int hashCode() { return this.getId().hashCode();