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

JobDsl should respect Job post-construction initialization

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • core, (1)
      job-dsl-plugin
    • None
    • Jenkins 2.168/2.193
      JobDsl plugin 1.72/1.77-SNAPSHOT

      Hello!
       
      we currently faced the following issue.
       
      If we run the creation of job via jobDsl pipeline step (https://jenkins.io/doc/pipeline/steps/job-dsl/) with any parameters, we are getting a folder on our filesystem without "legacyIds" file in builds directory.
      examples are in the bottom of this post.
      The problem is that if there is no legacyIds file in builds directory, after restarting of jenkins server, we are facing long migrations for all jobs created after the previous reboot
       

      Pull request with fix: https://github.com/jenkinsci/job-dsl-plugin/pull/1204

       
      Examples:
      job created via jobDsl:

      [root@server]# ls -lah builds/jobDsl_job
      total 2.5K
      drwxr-xr-x 1 centos centos 808K Sep 12 07:23 .
      drwxr-xr-x 1 centos centos 3.1G Sep 12 07:21 ..
      drwxr-xr-x 1 centos centos 808K Sep 12 07:23 1
      lrwxrwxrwx 1 centos centos    2 Sep 12 07:19 lastFailedBuild -> -1
      lrwxrwxrwx 1 centos centos    1 Sep 12 07:23 lastStableBuild -> 1
      lrwxrwxrwx 1 centos centos    1 Sep 12 07:23 lastSuccessfulBuild -> 1
      lrwxrwxrwx 1 centos centos    2 Sep 12 07:19 lastUnstableBuild -> -1
      lrwxrwxrwx 1 centos centos    2 Sep 12 07:19 lastUnsuccessfulBuild -> -1
      

      job created via manual creation:

      [root@server]# ls -lah builds/manual_job
      total 0
      drwxr-xr-x 1 centos centos    0 Sep 12 07:21 .
      drwxr-xr-x 1 centos centos 3.1G Sep 12 07:21 ..
      -rw-r--r-- 1 centos centos    0 Sep 12 07:21 legacyIds
      

          [JENKINS-59402] JobDsl should respect Job post-construction initialization

          Any updates on this issue?

          Konstantin Bulanov added a comment - Any updates on this issue?

          Shouldn't this be fixed in Jenkins core? Shouldn't createProjectFromXML() call onCreatedFromScratch() like createProject() does? And probably followed by save()?

          See https://github.com/jenkinsci/jenkins/blob/jenkins-2.223/core/src/main/java/hudson/model/ItemGroupMixIn.java

          When creating jobs from CLI, onCreatedFromScratch() is not called. Is that on purpose?
          https://github.com/jenkinsci/jenkins/blob/jenkins-2.223/core/src/main/java/hudson/cli/CreateJobCommand.java

          bulanovk can you check that with the core maintainers, maybe by creating a PR for core?

          Daniel Spilker added a comment - Shouldn't this be fixed in Jenkins core? Shouldn't createProjectFromXML() call onCreatedFromScratch() like createProject() does? And probably followed by save() ? See https://github.com/jenkinsci/jenkins/blob/jenkins-2.223/core/src/main/java/hudson/model/ItemGroupMixIn.java When creating jobs from CLI, onCreatedFromScratch() is not called. Is that on purpose? https://github.com/jenkinsci/jenkins/blob/jenkins-2.223/core/src/main/java/hudson/cli/CreateJobCommand.java bulanovk can you check that with the core maintainers, maybe by creating a PR for core?

            bulanovk Konstantin Bulanov
            bulanovk Konstantin Bulanov
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: