Skip to content

Commit ddeb114

Browse files
authored
Handle missing context in snippet generator (#675)
1 parent 0d3d553 commit ddeb114

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/main/java/com/microsoft/jenkins/azuread/AzureAdAuthorizationMatrixProperty.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ public FormValidation doCheckName(@AncestorInPath Job<?, ?> project, @QueryParam
113113
return Utils.undecidableResponse(value);
114114
}
115115

116+
// occurs in an empty multi-branch project
117+
if (project == null) {
118+
return Utils.undecidableResponse(value);
119+
}
120+
116121
return doCheckName_(value, project, Item.CONFIGURE);
117122
}
118123

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.microsoft.jenkins.azuread.AzureAdAuthorizationMatrixProperty
22

3+
import hudson.model.Item
34
import lib.FormTagLib
45
import org.jenkinsci.plugins.matrixauth.inheritance.InheritanceStrategyDescriptor
56

@@ -9,8 +10,9 @@ def st = namespace("jelly:stapler")
910
f.optionalBlock(name: 'useProjectSecurity', checked: instance != null, title: _("Enable project-based security")) {
1011
f.nested {
1112
div {
12-
f.dropdownDescriptorSelector(title: _("Inheritance Strategy"), descriptors: InheritanceStrategyDescriptor.getApplicableDescriptors(my.class), field: 'inheritanceStrategy')
13+
// It is unclear whether we can expect every Item to be an AbstractItem. While I've been unsuccessful finding one in a quick search, better be safe here and just offer fewer options if necessary.
14+
f.dropdownDescriptorSelector(title: _("Inheritance Strategy"), descriptors: InheritanceStrategyDescriptor.getApplicableDescriptors(my?.class?: Item.class), field: 'inheritanceStrategy')
1315
st.include(class: "com.microsoft.jenkins.azuread.AzureAdMatrixAuthorizationStrategy", page: "config")
1416
}
1517
}
16-
}
18+
}

0 commit comments

Comments
 (0)