Hi,
Can we define a pipeline DSL script importing a shared lib which is a java class ? Script @org.jenkinsci.plugins.workflow.libs.Library('mytools') import org.mytools.Messaging // The Java class imported as shared lib Messaging m = new Messaging(); The java class has been defined under the folder `src/main/org/mytools/Messaging.java` within the git project cloned as shared lib Cheers Charles
-- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/57934c26-d87f-4d39-88be-e829b4c94e9dn%40googlegroups.com. |
you can use directly a class from the Shared library
This is an example in our shared library (https://github.com/elastic/apm-pipeline-library) https://github.com/elastic/apm-pipeline-library/blob/master/src/co/elastic/matrix/DefaultParallelTaskGenerator.groovy and a pipeline that uses that class https://github.com/elastic/apm-integration-testing/blob/master/.ci/integrationTestDownstream.groovy#L89 El miércoles, 6 de enero de 2021 a las 18:23:12 UTC+1, [hidden email] escribió: Hi, You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/1216e835-5752-482f-b887-565bc4cc7194n%40googlegroups.com. |
Many thanks Ivan for the example which is a Groovy class and not a java class. According to the documentation, I don't think that we can use some java classes directly from a shared lib project excepted if thy have been compiled, packaged as jar under a maven repository and that you import it using "@Grab" - https://www.jenkins.io/doc/book/pipeline/shared-libraries/#using-third-party-libraries On Thu, Jan 7, 2021 at 6:02 PM Ivan Fernandez Calvo <[hidden email]> wrote: you can use directly a class from the Shared library You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAPb1sSt7t%2BSpafDcCW_dEykio6t316i-TTpJxwLPRD_xX1kTyQ%40mail.gmail.com. |
If a class is in the classpath, you can use it on a Pipeline Step or in a groovy class (the example), then you can use that step(or groovy class) in your pipeline. So instead of trying to load a jar file in runtime you can put the jar in the classpath of your Jenkins instance and wrap the class ina step (or groovy class)
El viernes, 8 de enero de 2021 a las 8:04:09 UTC+1, [hidden email] escribió:
You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/ea644d78-cd3d-4ebc-aa68-6dd1f379ae21n%40googlegroups.com. |
Free forum by Nabble | Edit this page |