Skip to content
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

[JENKINS-74867] Fix cloning entire parent folder when 'copy from' field is cleared after inputs #10098

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Lmh-java
Copy link
Contributor

@Lmh-java Lmh-java commented Dec 27, 2024

See JENKINS-74867.

Testing done

  • smoke-test
  • manual test, cannot reproduce the bug anymore.

Proposed changelog entries

Besides when retrieving the item to be copied by string, not only check if the path is null, but we should also check if the string is empty.

public Item getItem(String pathName, ItemGroup context) {
        if (context == null)  context = this;
        // check if pathName is "" as well
        if (Util.fixEmpty(pathName) == null) return null;

        if (pathName.startsWith("/"))   // absolute
            return getItemByFullName(pathName);

Why this bug occurs:
The backend reads in a "" (empty string) when user clears the 'copy from' field, which leads to getItem() function to return the parent directly. As a result, the parent of the current folder will be copied.

After the change, if the user tries to submit a new item when both 'job type' and 'copy from' are unset, the user will be prompted to specify which item to copy from. (as shown below)

image

Proposed upgrade guidelines

N/A

Submitter checklist

Preview Give feedback

Desired reviewers

@mention

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

Maintainer checklist

Preview Give feedback

PS: after this PR, I would do more work on this:

  • Improve UX in frontend. E.g. provide a radio button to allow the user to explicitly express their intentions to copy from existing items.

@MarkEWaite MarkEWaite added regression-fix Pull request that fixes a regression in one of the previous Jenkins releases bug For changelog: Minor bug. Will be listed after features labels Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug For changelog: Minor bug. Will be listed after features regression-fix Pull request that fixes a regression in one of the previous Jenkins releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants