workflow-cps-global-lib-plugin icon indicating copy to clipboard operation
workflow-cps-global-lib-plugin copied to clipboard

Allow shared libraries to be loaded from repo workspace

Open wesmcouch opened this issue 6 years ago • 8 comments

The purpose of this PR is to solve JENKINS-46721 - Expect library sources in custom subdirectory

This PR is a combination of ideas based on the work done in https://github.com/karolgil/SharedLibrary , https://github.com/jenkinsci/workflow-cps-global-lib-plugin/pull/40 and https://github.com/jenkinsci/workflow-cps-global-lib-plugin/pull/37

The WorkspaceLibraryAdder checks to see if any paths specified in @Library() exist in the workspace. If they exist those paths are added to the classpath of the non-trusted shell.

wesmcouch avatar Jun 29 '18 19:06 wesmcouch

@varju

wesmcouch avatar Jun 29 '18 19:06 wesmcouch

@karolgil @petr-motejlek @iocanel

wesmcouch avatar Jun 29 '18 19:06 wesmcouch

Would it be useful to provide an example here of how this would be used, along with a proposed addition to https://jenkins.io/doc/book/pipeline/shared-libraries/?

varju avatar Jun 30 '18 19:06 varju

Love it, looks like a nice addition. I agree that we need a working example of how to use it in Pipelines code.

Probably something like @Library("/src/org/customlib") _ right?

karolgil avatar Jul 02 '18 10:07 karolgil

Thanks for the suggestion, I have created an example of the shared library here. I wasn't able to find if the Jenkins documentation is in a public github repository, so if anyone has a link to that I can open a PR there too. If not the linked repo here can be added to the shared library documentation, and the example can be added to any example repository.

wesmcouch avatar Jul 03 '18 14:07 wesmcouch

This might be helpful but I don't think this addresses JENKINS-46721 in the right way as now you need to do changes in all your pipeline scripts in order to make a non-standard shared library structure work which is defined and configured in a complete different location.

IMHO https://github.com/jenkinsci/workflow-cps-global-lib-plugin/pull/40#pullrequestreview-96534557 in addition to this still makes sense.

doctorseus avatar Sep 11 '18 20:09 doctorseus

This is definitely a missing feature in the pipeline library support, and it would be great to see this PR merged.

nickbroon avatar Nov 12 '18 21:11 nickbroon

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 feature/workspace-library
git pull https://github.com/wesmcouch/workflow-cps-global-lib-plugin feature/workspace-library

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.

jglick avatar May 23 '22 23:05 jglick