workflow-cps-global-lib-plugin
workflow-cps-global-lib-plugin copied to clipboard
Allow shared libraries to be loaded from repo workspace
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.
@varju
@karolgil @petr-motejlek @iocanel
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/?
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?
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.
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.
This is definitely a missing feature in the pipeline library support, and it would be great to see this PR merged.
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.