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

Jenkins with custom build record root dir: renaming a job should create the new build record dir if it does not already exist

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved (View Workflow)
    • Minor
    • Resolution: Fixed
    • core
    • None

    Description

      We are using the (great) custom build record root directory feature, to store build records on an external location, at /some-static-path/${ITEM_FULLNAME}/builds

      So far so good.

      But when we rename a helloWorld job (which has build records) to helloWorld.newname, the rename succeeds, but throws this exception in the browser:

      Exception: failed to rename /some-static-path/helloWorld/builds to /some-static-path/helloWorld.newname/builds
      Stacktrace:
      java.io.IOException: failed to rename /some-static-path/helloWorld/builds to /some-static-path/helloWorld.newname/builds
      at hudson.model.Job.renameTo(Job.java:579)
      at hudson.model.Job.doDoRename(Job.java:1294)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:288)
      at org.kohsuke.stapler.interceptor.RequirePOST$Processor.invoke(RequirePOST.java:29)
      at org.kohsuke.stapler.Function$InterceptedFunction.invoke(Function.java:389)
      at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:151)
      at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:90)
      at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:111)

      It seems the main issue here is that the 'new' external location directory at /some-static-path/helloWorld.newname/builds does not yet exist. Is it possible to do a 'mkdir -p' to create this directory, before doing the renameTo?

      Attachments

        Issue Links

          Activity

            alex_ouzounis Alex Ouzounis added a comment -

            experiencing the same issue here.

            progress ?

            alex_ouzounis Alex Ouzounis added a comment - experiencing the same issue here. progress ?
            alex_ouzounis Alex Ouzounis added a comment - - edited

            Hi Daniel,

            Thanks for looking into it. Just for the record I am using Jenkins 1.570 and the rename seems to correctly to rename the job but not all builds get moved over. It also throws the exception below though.

            java.io.IOException: failed to rename /jenkinsBuilds/TEST_rename/builds to /jenkinsBuilds/TEST_rename_test/builds
            at hudson.model.Job.renameTo(Job.java:621)
            at hudson.model.Job.doDoRename(Job.java:1403)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:606)

            Looking at the actual file system I see:

            jenkins@XXX:/jenkinsBuilds/TEST_rename$ cd builds/
            jenkins@XXX:/jenkinsBuilds/TEST_rename/builds$ ls
            1 19 2014-07-30_17-23-04 2014-07-31_09-56-51 2014-07-31_10-26-19 28 lastFailedBuild
            10 2 2014-07-30_17-23-30 2014-07-31_09-57-16 2014-07-31_10-26-40 29 lastStableBuild
            11 20 2014-07-30_17-24-08 2014-07-31_09-57-57 2014-07-31_11-12-08 3 lastSuccessfulBuild
            12 2014-07-30_16-48-31 2014-07-30_17-24-54 2014-07-31_10-05-06 21 30 lastUnstableBuild
            13 2014-07-30_17-07-42 2014-07-31_09-29-30 2014-07-31_10-08-27 22 4 lastUnsuccessfulBuild
            14 2014-07-30_17-09-56 2014-07-31_09-30-18 2014-07-31_10-17-19 23 5
            15 2014-07-30_17-11-57 2014-07-31_09-42-30 2014-07-31_10-19-40 24 6
            16 2014-07-30_17-12-39 2014-07-31_09-51-33 2014-07-31_10-21-26 25 7
            17 2014-07-30_17-14-08 2014-07-31_09-54-51 2014-07-31_10-22-25 26 8
            18 2014-07-30_17-22-21 2014-07-31_09-55-25 2014-07-31_10-24-56 27 9

            ...

            jenkins@XXX:/jenkinsBuilds$ cd TEST_rename_test/
            jenkins@XXX:/jenkinsBuilds/TEST_rename_test$ ls
            builds
            jenkins@XXX:/jenkinsBuilds/TEST_rename_test$ cd builds/
            jenkins@XXX:/jenkinsBuilds/TEST_rename_test/builds$ ls
            28 30 lastFailedBuild lastStableBuild lastSuccessfulBuild lastUnstableBuild lastUnsuccessfulBuild

            It is fairly obvious something is going wrong. Manually copying the files sorts out the problem ofcourse.

            alex_ouzounis Alex Ouzounis added a comment - - edited Hi Daniel, Thanks for looking into it. Just for the record I am using Jenkins 1.570 and the rename seems to correctly to rename the job but not all builds get moved over. It also throws the exception below though. java.io.IOException: failed to rename /jenkinsBuilds/TEST_rename/builds to /jenkinsBuilds/TEST_rename_test/builds at hudson.model.Job.renameTo(Job.java:621) at hudson.model.Job.doDoRename(Job.java:1403) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) Looking at the actual file system I see: jenkins@XXX:/jenkinsBuilds/TEST_rename$ cd builds/ jenkins@XXX:/jenkinsBuilds/TEST_rename/builds$ ls 1 19 2014-07-30_17-23-04 2014-07-31_09-56-51 2014-07-31_10-26-19 28 lastFailedBuild 10 2 2014-07-30_17-23-30 2014-07-31_09-57-16 2014-07-31_10-26-40 29 lastStableBuild 11 20 2014-07-30_17-24-08 2014-07-31_09-57-57 2014-07-31_11-12-08 3 lastSuccessfulBuild 12 2014-07-30_16-48-31 2014-07-30_17-24-54 2014-07-31_10-05-06 21 30 lastUnstableBuild 13 2014-07-30_17-07-42 2014-07-31_09-29-30 2014-07-31_10-08-27 22 4 lastUnsuccessfulBuild 14 2014-07-30_17-09-56 2014-07-31_09-30-18 2014-07-31_10-17-19 23 5 15 2014-07-30_17-11-57 2014-07-31_09-42-30 2014-07-31_10-19-40 24 6 16 2014-07-30_17-12-39 2014-07-31_09-51-33 2014-07-31_10-21-26 25 7 17 2014-07-30_17-14-08 2014-07-31_09-54-51 2014-07-31_10-22-25 26 8 18 2014-07-30_17-22-21 2014-07-31_09-55-25 2014-07-31_10-24-56 27 9 ... jenkins@XXX:/jenkinsBuilds$ cd TEST_rename_test/ jenkins@XXX:/jenkinsBuilds/TEST_rename_test$ ls builds jenkins@XXX:/jenkinsBuilds/TEST_rename_test$ cd builds/ jenkins@XXX:/jenkinsBuilds/TEST_rename_test/builds$ ls 28 30 lastFailedBuild lastStableBuild lastSuccessfulBuild lastUnstableBuild lastUnsuccessfulBuild It is fairly obvious something is going wrong. Manually copying the files sorts out the problem ofcourse.
            danielbeck Daniel Beck added a comment -

            It's fairly obvious from the source code diff of the linked issue that the code assumes the parent directory to exist.

            I.e. /foo/bar/${ITEM_FULL_NAME} is OK, /foo/bar/${ITEM_FULL_NAME}/baz is not.

            Will likely also fail when using Folders plugin so ITEM_FULL_NAME is multiple nested dirs.

            danielbeck Daniel Beck added a comment - It's fairly obvious from the source code diff of the linked issue that the code assumes the parent directory to exist. I.e. /foo/bar/${ITEM_FULL_NAME} is OK, /foo/bar/${ITEM_FULL_NAME}/baz is not. Will likely also fail when using Folders plugin so ITEM_FULL_NAME is multiple nested dirs.

            Code changed in jenkins
            User: Daniel Beck
            Path:
            core/src/main/java/hudson/model/Job.java
            core/src/main/java/jenkins/model/Jenkins.java
            test/src/test/java/hudson/model/JobTest.java
            http://jenkins-ci.org/commit/jenkins/7f4014c74047d96b1557eae09d06853fd841beb4
            Log:
            [FIXED JENKINS-19764] Ensure parent dir of new builds dir exists.

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Daniel Beck Path: core/src/main/java/hudson/model/Job.java core/src/main/java/jenkins/model/Jenkins.java test/src/test/java/hudson/model/JobTest.java http://jenkins-ci.org/commit/jenkins/7f4014c74047d96b1557eae09d06853fd841beb4 Log: [FIXED JENKINS-19764] Ensure parent dir of new builds dir exists.

            Code changed in jenkins
            User: Daniel Beck
            Path:
            core/src/main/java/hudson/model/Job.java
            core/src/main/java/jenkins/model/Jenkins.java
            test/src/test/java/hudson/model/JobTest.java
            http://jenkins-ci.org/commit/jenkins/9bc2f1d057b49b7a802eb9a39a6412adaa7acc73
            Log:
            Merge pull request #1377 from daniel-beck/JENKINS-19764

            [FIXED JENKINS-19764] Ensure parent dir of new builds dir exists.

            Compare: https://github.com/jenkinsci/jenkins/compare/4bc1043244c8...9bc2f1d057b4

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Daniel Beck Path: core/src/main/java/hudson/model/Job.java core/src/main/java/jenkins/model/Jenkins.java test/src/test/java/hudson/model/JobTest.java http://jenkins-ci.org/commit/jenkins/9bc2f1d057b49b7a802eb9a39a6412adaa7acc73 Log: Merge pull request #1377 from daniel-beck/ JENKINS-19764 [FIXED JENKINS-19764] Ensure parent dir of new builds dir exists. Compare: https://github.com/jenkinsci/jenkins/compare/4bc1043244c8...9bc2f1d057b4
            dogfood dogfood added a comment -

            Integrated in jenkins_main_trunk #3671
            [FIXED JENKINS-19764] Ensure parent dir of new builds dir exists. (Revision 7f4014c74047d96b1557eae09d06853fd841beb4)

            Result = UNSTABLE
            daniel-beck : 7f4014c74047d96b1557eae09d06853fd841beb4
            Files :

            • core/src/main/java/hudson/model/Job.java
            • test/src/test/java/hudson/model/JobTest.java
            • core/src/main/java/jenkins/model/Jenkins.java
            dogfood dogfood added a comment - Integrated in jenkins_main_trunk #3671 [FIXED JENKINS-19764] Ensure parent dir of new builds dir exists. (Revision 7f4014c74047d96b1557eae09d06853fd841beb4) Result = UNSTABLE daniel-beck : 7f4014c74047d96b1557eae09d06853fd841beb4 Files : core/src/main/java/hudson/model/Job.java test/src/test/java/hudson/model/JobTest.java core/src/main/java/jenkins/model/Jenkins.java

            People

              danielbeck Daniel Beck
              sroth Steve Roth
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: