feat: add dropdown for resource select strategies and fix empty resource strategy in pipeline syntax#767
Conversation
| return RequiredResourcesProperty.DescriptorImpl.doAutoCompleteResourceNames(value, item); | ||
| } | ||
|
|
||
| public ListBoxModel doFillResourceSelectStrategyItems() { |
Check warning
Code scanning / Jenkins Security Scan
Stapler: Missing permission check Warning
There was a problem hiding this comment.
From my understanding this is a false positive since the resource strategy is available regardless of permissions? However, I see that there is a permission check in
but not sure whyThere was a problem hiding this comment.
because of security. Just add the same check like in other dSomething actions and every body will be happy.
| @DataBoundSetter | ||
| public void setResourceSelectStrategy(String resourceSelectStrategy) { | ||
| this.resourceSelectStrategy = resourceSelectStrategy; | ||
| if (resourceSelectStrategy != null && !resourceSelectStrategy.isEmpty()) { |
There was a problem hiding this comment.
I think, it will be better to thrown some exceptuion here. Because, like in ouir example, empty string is still not valid. The code will do some default things, and nobody will catch the developer failure.
This PR fixes a bug in the Pipeline Syntax and improves its UX.
fix: in /pipeline-syntax, when not specifying anything under "Strategy for resource selection", it would return an empty string in the generated snippet, which is an invalid input:

To resolve this, a null/empty check was added.
feat: add dropdown for resource select strategies
While the comments state which values are valid, it can also be parsed from the enum and can be made available via dropdown.
With these changes, it looks like this:

Testing done
I consider this to be a minor change without tests requiring adaption. If you think different, let me know.
Proposed upgrade guidelines
N/A
Localizations
N/A
Submitter checklist
@NoExternalUse. In case it is used by non java code theUsed by {@code <panel>.jelly}Javadocs are annotated. [No function in this file does this, so I left it out as well)evalto ease the future introduction of Content Security Policy (CSP) directives (see documentation).Maintainer checklist
Before the changes are marked as
ready-for-merge:upgrade-guide-neededlabel is set and there is a Proposed upgrade guidelines section in the pull request title (see example).