Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-21087

Don't hold off building until saved for jobs copied and updated from REST API

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • core
    • None

    Description

      Jenkins version 1.544.

      I use the python jenkinsapi-0.2.16-py2.7 to copy a job and then get it's config, modify it and update it.

      After that, the job is not buildable. If I disable it and reenable it again, it's buildable again.

      I think this is a regression when JENKINS-2494 was fixed. It worked well some Jenkins versions back. Se also JENKINS-20744 which deals with a similar problem for the CLI.

      This is my python function that configures the job (XXX = censored info):

      def create_job(template_job, new_job, enable=True, verbose=False, debug=False, **context):
      """
      Create a job from a template job.
      """

      j = jenkins.Jenkins('http://XXX', username='XXX', password='XXX')

      if j.has_job(template_job):
      templ_job = j.get_job(template_job)
      else:
      print "Couldn't find template job " + template_job
      sys.exit(1)

      if not j.has_job(new_job):
      if verbose:
      print "Creating new job " + new_job
      job = j.copy_job(template_job, new_job)
      else:
      job = j.get_job(new_job)
      if verbose:
      print "Modifying already existing job " + new_job

      config = templ_job.get_config()
      new_config = create_config(config, enable, **context)
      job.update_config(new_config)

      Attachments

        Issue Links

          Activity

            danielbeck Daniel Beck added a comment -

            Seems like huson.model.Job does clear the holdOffBuildUntilUserSave flag when calling save(), but not when calling updateByXml(…). This can probably solved by implementing updateByXml(…) in Job calling super's implementation and clearing the flag.

            danielbeck Daniel Beck added a comment - Seems like huson.model.Job does clear the holdOffBuildUntilUserSave flag when calling save() , but not when calling updateByXml(…) . This can probably solved by implementing updateByXml(…) in Job calling super 's implementation and clearing the flag.

            Any plans to fix this issue or a suggestion for a workaround that I can use from the REST API?

            I use this feature to create a quite large number of jobs and it's not really feasible to disable/enable them manually and I can't restart Jenkins either since it's running jobs all the time.

            magjac Magnus Jacobsson added a comment - Any plans to fix this issue or a suggestion for a workaround that I can use from the REST API? I use this feature to create a quite large number of jobs and it's not really feasible to disable/enable them manually and I can't restart Jenkins either since it's running jobs all the time.

            Found a workaround myself. I use jenkinsapi job.disable() and job.enable().

            magjac Magnus Jacobsson added a comment - Found a workaround myself. I use jenkinsapi job.disable() and job.enable().

            People

              Unassigned Unassigned
              magjac Magnus Jacobsson
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: