Home > Back-end >  seed-job fails fails to parse build user vars plugin
seed-job fails fails to parse build user vars plugin

Time:11-05

I have the below code in my Jenkins job (pipeline script):

def user_id = ''
wrap([$class: 'BuildUser']) {
    addBadge text: env.BUILD_USER   ', '   params.Computer
    user_id = env.BUILD_USER_ID.toLowerCase()
}   

But the code fails in the seed-job with:

javaposse.jobdsl.dsl.DslException: startup failed:
script: 106: unexpected token: class
       wrap([$class: 'BuildUser']) {
              ^

1 error

I've found this suggestion but then groovy syntax throws error of: unexpected char : '\'

Any idea how to solve this?

CodePudding user response:

The solution was to warp the entire script code in single quotes instead double quotes (in myjob.jobdsl file):

definition {
 cps {
  script('''
   def user_id = ''
   wrap([$class: 'BuildUser']) {
      addBadge text: env.BUILD_USER   ', '   params.Computer
      user_id = env.BUILD_USER_ID.toLowerCase()
   }
  ''')
 }
}
  • Related