Well, not exactly. I found a workaround by reworking the entire logic. My landscape is: one master declarative pipeline kicks off multiple child pipeline jobs. Both the master and the child pipelines are instances created out of shared libraries (jobBuilder, pipelineBuilder) and I want to be able to run the child items as standalone pipelines (in isolation) as well as running them from master pipeline context (different params).
The child job's Jenkins file looks like this (the syntax is not declarative but scripted - the shared library is loaded on the first line): library identifier: 'templates@branches/rel/10.4.0.x/build/change-management/jenkinsfiles/templates', retriever: modernSCM([$class: 'SubversionSCMSource', remoteBase: 'SVN', credentialsId: 'USER']) stage('Run Test Suite') { jobBuilder { nodeLabels = 'linux' antExtraArgs = 'test -Dtest.suite=com.pcbsys.suites.nJMS.PromotionTests' jobTimeoutHours = 3 } } jobsdsl syntax was used only to create the actual Jenkins child pipeline: script { for (String jobName : allJobs) { jobDsl scriptText: """ pipelineJob('${nirvanaMajor}.${nirvanaMinor}_${devJobPrefix}${jobName}') { parameters { stringParam('branch','${svnBranch}','svn repository url') stringParam('buildmajor',"${nirvanaMajor}",'release major identifier') stringParam('buildminor',"${nirvanaMinor}",'release minor identifier') stringParam('fix', '${env.fix}','fix level') stringParam('buildnumber', '${env.buildNumber}','artifacts build number') stringParam('revision', '${env.buildNumber}','checkout revision') stringParam('parentjob', '${pipelineName}','optional parent job') } removedJobAction: 'IGNORE' definition { cpsScm { scm { svn { location ('${svnBranch}/${jobName}') { credentials('user') } } } scriptPath('Jenkinsfile') } } } """.stripIndent() } } On Monday, December 17, 2018 at 11:51:39 PM UTC+2, Philip Steiner wrote: > > Hi tre..., I know this thread is getting old, but did you ever get an > answer or figure out how to use a Jenkins Shared Library in the Job DSL > script, or some workaround? > > Thanks > Philip > -- 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/75affe01-2fb0-4766-9867-d1873d5048e0%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.