hi Philip,
It's possible
@Grab('org.yaml:snakeyaml:1.17')
import org.yaml.snakeyaml.Yaml ......
def params = readFileFromWorkspace(param.getPath())
yamlMap = new Yaml().load(params)
yamlMap.each { key, value ->
....
}
Works for me just use yaml module & groovy. In my case shared libraries are
placed in the same repository where the seed job dsl is sitting.
вторник, 18 декабря 2018 г., 14:28:45 UTC-5 пользователь Philip Steiner
написал:
>
> Thanks for the detailed followup! Lots to digest. It looks like you were
> having trouble accessing the Shared Library from generated pipeline
> scripts, which is a little different from my problem: I want to reference
> YAML data files stored in the Jenkins Shared Library from inside a Job DSL
> script, but now it appears that's not possible (at least I don't see
> anything like @Library for the Job DSL API), so I think I also need to
> rework the overall logic for my build environment.
>
> On Tuesday, December 18, 2018 at 4:27:57 AM UTC-8, [email protected] wrote:
>>
>> 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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/9108f06d-c129-4d46-b0ee-e259bc948ef4%40googlegroups.com.