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

Allowing a library name to be passed to the libraryResource step #49

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jmcshane
Copy link

This would allow Jenkinsfile authors to specify the library name that is included to avoid duplication across resources.

Copy link
Member

@dwnusbaum dwnusbaum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a useful change to me!

if (contents.isEmpty()) {
if (libraryName != null && contents.containsKey(libraryName)) {
return contents.get(libraryName);
} else if (contents.isEmpty() || (libraryName != null && !contents.containsKey(libraryName))) {
Copy link
Member

@dwnusbaum dwnusbaum Aug 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to have different error message for the libraryName != null && !contents.containsKey(libraryName)) condition saying the resource was found, but not in the specified library, or that has a similar message as the current one but includes the library name.


@DataBoundSetter
public void setLibraryName(String libraryName) {
this.libraryName = libraryName;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use = Util.fixEmptyAndTrim(libraryName) to remove surrounding whitespace from libraryName.

@dwnusbaum
Copy link
Member

I just merged #48 which introduced a merge conflict, sorry! Also, it would be great to add a help-libraryName.html file explaining how to use the new parameter (similarly to what was done for the encoding parameter in #48).

@jmcshane
Copy link
Author

I should be able to get around to these comments today, I’ll make sure to rebase and resolve that conflict.

@jmcshane
Copy link
Author

jmcshane commented Sep 6, 2018

@dwnusbaum Could you check now? Thanks!

@dwnusbaum dwnusbaum self-requested a review September 6, 2018 20:44
Copy link
Member

@dwnusbaum dwnusbaum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmcshane Thanks for updating the PR! The changes look good to me (thanks for the tests!), I just had some minor comments about the help messages. I'd appreciate if another reviewer could take a quick look before merging.

@@ -23,3 +23,4 @@
LibraryDecorator.could_not_find_any_definition_of_librari=Could not find any definition of libraries {0}
ResourceStep.library_resource_ambiguous_among_librari=Library resource {0} ambiguous among libraries {1}
ResourceStep.no_such_library_resource_could_be_found_=No such library resource {0} could be found.
ResourceStep.no_matching_resource_found_in_library=Library resource {0} not found in library {1}, but was present in other library
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Maybe reword to: "Library resource {0} not found in library {1}, although it was present in libraries {2}" and pass contents.keySet() as the third argument.

@@ -0,0 +1,5 @@
<div>
The shared library name to use to locate the resource.
If left blank, all loaded shared libraries will be loaded.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Maybe reword to "If left blank, then this step will search for the resource in all configured shared libraries."

@jglick
Copy link
Member

jglick commented Oct 8, 2018

Tread carefully here. I am not convinced this is safe, which is why I did not offer such an option to begin with.

@jglick
Copy link
Member

jglick commented Oct 8, 2018

Also from a usage perspective this is dubious. libraryResource is normally called from library code. But a library does not, in general, know its own name—this is picked arbitrarily by an administrator. So you could not use this feature portably. It could only be used by a library written for exclusive use in a particular environment. But then why would there be duplication?

It would be helpful to have an explanation of what the original problem was which you are attempting to solve via this feature.

@caporegim
Copy link

Any progress with this pull request?

@jglick
Copy link
Member

jglick commented May 23, 2022

As of #172 most of the code in this plugin has been moved to another plugin repository so this PR must be closed. If this change is still needed, please

git clone https://github.com/jenkinsci/pipeline-groovy-lib-plugin
cd pipeline-groovy-lib-plugin
git checkout -b SELECT-BRANCH-NAME
git pull https://github.com/jmcshane/workflow-cps-global-lib-plugin master

resolve any merge conflicts, and file a fresh PR on the new repository. Be sure to paste a link to this old PR to enable bidirectional navigation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants