-
Notifications
You must be signed in to change notification settings - Fork 196
feat: add dropdown for resource select strategies and fix empty resource strategy in pipeline syntax #767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
lockable-resources-plugin/src/main/java/org/jenkins/plugins/lockableresources/LockStep.java
Lines 172 to 177 in 4030359
| // check permission, security first | |
| if (item != null) { | |
| item.checkPermission(Item.CONFIGURE); | |
| } else { | |
| Jenkins.get().checkPermission(Jenkins.ADMINISTER); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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).