Manage Jenkins -> configure system -> global libraries

You can add your shared library there.

On Fri, Aug 17, 2018 at 11:05 <[email protected]> wrote:

> Hey,
>
> I am looking for advice how to achieve usage of Jenkins shared library in
> Job DSL –
> I use this snipped to seed a job whose functionality is in Jenkins file:
>
>
> job('my-small-test-job') {
> parameters {
> stringParam('branch', '${branch}')
> }
> removedJobAction: 'IGNORE'
> def releaseScript = readFileFromWorkspace('Jenkinsfile')
> steps {
>       dsl {
>       text(releaseScript)
>       }
> }
> }
>
> The newly created [my-small-test-job] has this content (taken out of the
> Jenkinsfile):
>
> @Library('templates')_
>
> stage('Demo') {
>     echo 'Hello world'
>     jobBuilder {
>       nodeLabels = 'linux && test'
>       antExtraArgs = 'test
> -Dtest.suite=com.softwareag.suites.custom.ToolsTestSuite'
> }
> }
>
> I have a shared library under [templates] that is a generic job builder
> (the syntax is typical groovy like jenkins pipeline, similar to what is
> explained here: https://jenkins.io/doc/book/pipeline/shared-libraries/)
>
>
> When I try to run the newly created [my-small-test-job] I get this:
>
> Processing provided DSL script
> ERROR: startup failed:
> script: 1: unable to resolve class Library ,  unable to find class for
> annotation
>  @ line 1, column 1.
>    @Library('templates')_
>    ^
>
> 1 error
>
>
> The shared library is obviusly not added to classpath. How do I fix this?
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/6e3b23aa-873b-40c6-9859-c5cd7356611f%40googlegroups.com
> <https://groups.google.com/d/msgid/jenkinsci-users/6e3b23aa-873b-40c6-9859-c5cd7356611f%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CADgiF9LMjNNruE_pux-K5Gqy_UabB0KHdZwiHWVG3a7AhzSP-Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to