Skip to content

Commit 916486e

Browse files
committed
Add isBuildable to BuildableItem interface
When disabling a Multibranch project the branch/PR jobs still show the build button in the sidepanel and in the folder view the Build button column allows to start a build. By adding the isBuildable to the BuildableItem interface we can now detect in Jobs if the parent is disabled. This will then hide the build button in the sidepanel and the column in the view. fixes #16678
1 parent 1ce1de6 commit 916486e

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

core/src/main/java/hudson/model/BuildableItem.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,8 @@ default boolean scheduleBuild(int quietPeriod) {
5757
}
5858

5959
boolean scheduleBuild(int quietPeriod, Cause c);
60+
61+
default boolean isBuildable() {
62+
return true;
63+
};
6064
}

core/src/main/java/jenkins/model/ParameterizedJobMixIn.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import hudson.model.Cause;
4141
import hudson.model.CauseAction;
4242
import hudson.model.Item;
43+
import hudson.model.ItemGroup;
4344
import hudson.model.Items;
4445
import hudson.model.Job;
4546
import hudson.model.ParameterDefinition;
@@ -562,8 +563,19 @@ default RunT createExecutable() throws IOException {
562563
return null;
563564
}
564565

566+
@Override
565567
default boolean isBuildable() {
566-
return !isDisabled() && !((Job) this).isHoldOffBuildUntilSave();
568+
if (isDisabled() || ((Job) this).isHoldOffBuildUntilSave()) {
569+
return false;
570+
}
571+
// If parent is disabled, child jobs (e.g., branch jobs) should not be buildable
572+
ItemGroup<? extends Item> parentGroup = ((Job) this).getParent();
573+
if (parentGroup instanceof BuildableItem bi) {
574+
if (!bi.isBuildable()) {
575+
return false;
576+
}
577+
}
578+
return true;
567579
}
568580

569581
@Extension

0 commit comments

Comments
 (0)