jjb fails on creating job with spaces in the name

Bug #1247866 reported by David Schmitt
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Core Infrastructure
Invalid
Medium
Yolanda Robla

Bug Description

when creating a jenkins job that contains spaces in the name, jenkins-job-builder fails with an exception:

jenkins@jenkins:~/jobbuilder/tests$ ~/jobbuilder/usr/bin/jenkins-jobs --conf ~/jobbuilder/jjb.ini update ~/jobbuilder/tests
INFO:root:Updating jobs in /var/lib/jenkins/jobbuilder/tests ([])
INFO:jenkins_jobs.builder:Creating jenkins job Jenkins Config Backup
Traceback (most recent call last):
  File "/var/lib/jenkins/jobbuilder/usr/bin/jenkins-jobs", line 9, in <module>
    load_entry_point('jenkins-job-builder==0.5.0.139.g2ecc954', 'console_scripts', 'jenkins-jobs')()
  File "/var/lib/jenkins/jobbuilder/usr/lib/python2.7/site-packages/jenkins_job_builder-0.5.0.139.g2ecc954-py2.7.egg/jenkins_jobs/cmd.py", line 114, in main
    jobs = builder.update_job(options.path, options.names)
  File "/var/lib/jenkins/jobbuilder/usr/lib/python2.7/site-packages/jenkins_job_builder-0.5.0.139.g2ecc954-py2.7.egg/jenkins_jobs/builder.py", line 521, in update_job
    self.jenkins.update_job(job.name, job.output())
  File "/var/lib/jenkins/jobbuilder/usr/lib/python2.7/site-packages/jenkins_job_builder-0.5.0.139.g2ecc954-py2.7.egg/jenkins_jobs/builder.py", line 416, in update_job
    self.jenkins.create_job(job_name, xml)
  File "/usr/lib/python2.7/dist-packages/jenkins/__init__.py", line 287, in create_job
    raise JenkinsException('create[%s] failed'%(name))
jenkins.JenkinsException: create[Jenkins Config Backup] failed
jenkins@jenkins:~/jobbuilder/tests$

Changing the name of the job to use dashes instead of spaces fixed the problem:

jenkins@jenkins:~/jobbuilder/tests$ ~/jobbuilder/usr/bin/jenkins-jobs --conf ~/jobbuilder/jjb.ini update ~/jobbuilder/tests
INFO:root:Updating jobs in /var/lib/jenkins/jobbuilder/tests ([])
INFO:jenkins_jobs.builder:Creating jenkins job jenkins-config-backup
jenkins@jenkins:~/jobbuilder/tests$

Revision history for this message
David Schmitt (david-dasz) wrote :

I'm using Jenkins ver. 1.537 on Debian GNU/Linux 7.2 (wheezy)

Revision history for this message
David Schmitt (david-dasz) wrote :

The job existed already on the jenkins, so I'm wondering why jjb wanted to "create" the job.

James E. Blair (corvus)
Changed in openstack-ci:
status: New → Triaged
importance: Undecided → Medium
tags: added: low-hanging-fruit
Mathieu Gagné (mgagne)
tags: added: jjb
removed: jenkins-job-builder
Changed in openstack-ci:
assignee: nobody → Yolanda Robla (yolanda.robla)
Revision history for this message
Yolanda Robla (yolanda.robla) wrote :

Problem is in python-jenkins, not properly encoding the parameters received to build urls. Tried to encode them from jenkins-job-builder but there are some cases that need to be patched directly in python-jenkins.
Should i send some change to python-jenkins or just prevent people to send problematic job names to jenkins-job-builder? (maybe matching some regex for name)

Revision history for this message
Khai Do (zaro0508) wrote :

IMO it's better to patch python-jenkins. I also submitted a patch so after your patch we can ask jeblair to merge the changes.

Revision history for this message
Yolanda Robla (yolanda.robla) wrote :

Tested using latest python-jenkins version, and works fine because it correctly escapes results now. So updating to the latest python-jenkins version should solve this.

Changed in openstack-ci:
status: Triaged → In Progress
Changed in openstack-ci:
status: In Progress → Incomplete
Revision history for this message
Khai Do (zaro0508) wrote :

There's been a few releases of python-jenkins since 2013-01-08. Is this still an issue?

Revision history for this message
Yolanda Robla (yolanda.robla) wrote :

With latest python versions it works fine

Changed in openstack-ci:
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.