Currently there are pairs of methods differentiated by Item vs. ItemGroup, which is clumsy. For use from
JENKINS-38048 it is desirable to let the Item overloads accept null, so that you can populate global credentials when in a global configuration screen.
The suggestion is to deprecate all these, replacing them with methods¹ taking @Nonnull ModelObject, a common supertype. Call sites could either use @AncestorInPath ModelObject context, or continue to search for Item and pass context != null ? context : Jenkins.getInstance().
For a context which is neither Item nor ItemGroup, to start with just fall back to Jenkins.getInstance(). Later these could provide special handling for User, Node, etc.
To simplify passing an @NonNull Authentication argument, there should be a helper method along the lines of
which call sites could call something like:
¹Perhaps methods with new names rather than overloads. Or perhaps overloads with different argument ordering. Overloads with the same argument ordering would not work, since existing overloads would be considered more specific by the Java compiler unless you disambiguated with an explicit cast.
|Remote Link||This issue links to "CloudBees Internal CD-292 (Web Link)" [ 19507 ]|
|Assignee||Stephen Connolly [ stephenconnolly ]|