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()