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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/6e3b23aa-873b-40c6-9859-c5cd7356611f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to