Skip to content

Conversation

@meiswjn
Copy link

@meiswjn meiswjn commented Apr 3, 2025

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:
image
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:
image

Testing done

I consider this to be a minor change without tests requiring adaption. If you think different, let me know.

  • Tested /pipeline-syntax
  • Tested /directive-generator

Proposed upgrade guidelines

N/A

Localizations

N/A

Submitter checklist

  • The Jira / Github issue, if it exists, is well-described.
  • The changelog entries and upgrade guidelines are appropriate for the audience affected by the change (users or developers, depending on the change) and are in the imperative mood (see examples).
    • The changelog generator for plugins uses the pull request title as the changelog entry.
    • Fill in the Proposed upgrade guidelines section only if there are breaking changes or changes that may require extra steps from users during the upgrade.
  • There is automated testing or an explanation that explains why this change has no tests.
  • New public functions for internal use only are annotated with @NoExternalUse. In case it is used by non java code the Used by {@code <panel>.jelly} Javadocs are annotated. [No function in this file does this, so I left it out as well)
  • New or substantially changed JavaScript is not defined inline and does not call eval to ease the future introduction of Content Security Policy (CSP) directives (see documentation).
  • For dependency updates, there are links to external changelogs and, if possible, full differentials.
  • For new APIs and extension points, there is a link to at least one consumer.
  • Any localizations are transferred to *.properties files.
  • Changes in the interface are documented also as examples.

Maintainer checklist

Before the changes are marked as ready-for-merge:

  • There is at least one (1) approval for the pull request and no outstanding requests for change.
  • Conversations in the pull request are over, or it is explicit that a reviewer is not blocking the change.
  • Changelog entries in the pull request title and/or Proposed changelog entries are accurate, human-readable, and in the imperative mood.
  • Proper changelog labels are set so that the changelog can be generated automatically. See also release-drafter-labels.
  • If the change needs additional upgrade steps from users, the upgrade-guide-needed label is set and there is a Proposed upgrade guidelines section in the pull request title (see example).
  • java code changes are tested by automated test.

return RequiredResourcesProperty.DescriptorImpl.doAutoCompleteResourceNames(value, item);
}

public ListBoxModel doFillResourceSelectStrategyItems() {

Check warning

Code scanning / Jenkins Security Scan

Stapler: Missing permission check Warning

Potential missing permission check in DescriptorImpl#doFillResourceSelectStrategyItems
Copy link
Author

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

// check permission, security first
if (item != null) {
item.checkPermission(Item.CONFIGURE);
} else {
Jenkins.get().checkPermission(Jenkins.ADMINISTER);
}
but not sure why

Copy link
Contributor

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.

@meiswjn meiswjn marked this pull request as ready for review April 3, 2025 13:28
@meiswjn meiswjn requested a review from a team as a code owner April 3, 2025 13:28
@DataBoundSetter
public void setResourceSelectStrategy(String resourceSelectStrategy) {
this.resourceSelectStrategy = resourceSelectStrategy;
if (resourceSelectStrategy != null && !resourceSelectStrategy.isEmpty()) {
Copy link
Contributor

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.

@mPokornyETM mPokornyETM added bug work-in-progress java Pull requests that update Java code ui Features that may impact UI, pages made by the plugin or external UIs (BO, legacy, etc.) labels Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug java Pull requests that update Java code ui Features that may impact UI, pages made by the plugin or external UIs (BO, legacy, etc.) work-in-progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants