gvalkov / jenkins-autojobs

Automatically create Jenkins jobs from template jobs and branches in a SCM repository
http://jenkins-autojobs.rtfd.org
Other
49 stars 39 forks source link

Substitution not working for some elements #39

Closed stephaneerard closed 9 years ago

stephaneerard commented 9 years ago

I have a job template which I want to run another job template.

A: JOB-BUILD-{branch} B: JOB-PACKAGE-{branch}

In the configuration page of A I add a config to build another project after this one. In this config I set as job : JOB-PACKAGE-@@JOB_NAME@@

I get this error :

processing ref: refs/heads/develop
. job name: FRONT-SEARCH-BRANCH-develop
. job exists: True
Traceback (most recent call last):
  File "/usr/local/bin/jenkins-makejobs-git", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/jenkins_autojobs/git.py", line 125, in main
    _main(argv[1:], config=config, create_job=create_job, list_branches=list_branches)
  File "/usr/local/lib/python2.7/dist-packages/jenkins_autojobs/main.py", line 154, in main
    job_name = create_job(branch, tmpl, config, branch_config)
  File "/usr/local/lib/python2.7/dist-packages/jenkins_autojobs/git.py", line 115, in create_job
    job.substitute(list(ref_config['substitute'].items()), fmtdict, groups, groupdict)
  File "/usr/local/lib/python2.7/dist-packages/jenkins_autojobs/job.py", line 52, in substitute
    nv = p.text.replace(k, v.format(*groups, **ctx))
KeyError: 'branch'

I have tested with {branch} too with same error.

Thank you very much !

stephaneerard commented 9 years ago

Hmmm sorry I got it wrong using «{branch}» : There is no error + {branch} does not get substitued, making me thinking that @@JOB_NAME@@ are the ones being searched.

Thanks

stephaneerard commented 9 years ago

Closing, I came to understand how it wors, again.... Sorry ;) My yml config looks like

substitute:
  '@@BRANCH@@' : '{shortref}'

What was causing the problem was that I was using wrong Key (KeyError !):

substitute: '@@BRANCH@@' : '{branch}'

The key «branch» is not something substituable.

gvalkov commented 9 years ago

Happy to hear things worked out. I should definitely spend some more time on the documentation ...