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

Jenkins needs to check whether the war's directory is writeable before offering to upgrade

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • core

      Lifecycle#canRewriteHudsonWar assumes in-place replacement of the war, while UpdateCenter#download actually writes to a temporary file first to prevent breaking the file if an error occurs. This can lead to the following exception:

      hudson.util.IOException2: Failed to download from http://updates.jenkins-ci.org/download/war/1.570/jenkins.war (redirected to: http://jenkins.mirror.isppower.de/war/1.570/jenkins.war)
      	at hudson.model.UpdateCenter$UpdateCenterConfiguration.download(UpdateCenter.java:791)
      	at hudson.model.UpdateCenter$DownloadJob._run(UpdateCenter.java:1138)
      	at hudson.model.UpdateCenter$DownloadJob.run(UpdateCenter.java:1116)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      	at hudson.remoting.AtmostOneThreadExecutor$Worker.run(AtmostOneThreadExecutor.java:104)
      	at java.lang.Thread.run(Thread.java:744)
      Caused by: java.io.FileNotFoundException: /usr/lib/jenkins/jenkins.war.tmp (Permission denied)
      	at java.io.FileOutputStream.open(Native Method)
      	at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
      	at java.io.FileOutputStream.<init>(FileOutputStream.java:171)
      	at hudson.model.UpdateCenter$UpdateCenterConfiguration.download(UpdateCenter.java:762)
      	... 6 more

          [JENKINS-23683] Jenkins needs to check whether the war's directory is writeable before offering to upgrade

          Harald Albers added a comment -

          Under which circumstances does such an error occur? How could I reproduce it?

          Harald Albers added a comment - Under which circumstances does such an error occur? How could I reproduce it?

          Daniel Beck added a comment - - edited

          Harald: For me, it was because I installed from RPM and decided I want Jenkins to be auto-upgradeable. So I ran chown jenkins /usr/lib/jenkins/jenkins.war. The button to Upgrade Automatically did appear, as did the exception after I clicked it. The jenkins user needs write access to the containing folder, as that is where the downloaded file is stored.

          An alternative solution have been to download to a guaranteed writable file in the temp dir, but being able to rename the .war to .bak (backup file) before upgrading seems like a good idea as well, so now the button only shows up when the folder is writable as well.

          Daniel Beck added a comment - - edited Harald: For me, it was because I installed from RPM and decided I want Jenkins to be auto-upgradeable. So I ran chown jenkins /usr/lib/jenkins/jenkins.war . The button to Upgrade Automatically did appear, as did the exception after I clicked it. The jenkins user needs write access to the containing folder, as that is where the downloaded file is stored. An alternative solution have been to download to a guaranteed writable file in the temp dir, but being able to rename the .war to .bak (backup file) before upgrading seems like a good idea as well, so now the button only shows up when the folder is writable as well.

          Code changed in jenkins
          User: Daniel Beck
          Path:
          core/src/main/java/hudson/lifecycle/Lifecycle.java
          http://jenkins-ci.org/commit/jenkins/b06e2aa3414d480d8b44459b0632226921be85f6
          Log:
          [FIXED JENKINS-23683] Check whether war's directory is writable

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Daniel Beck Path: core/src/main/java/hudson/lifecycle/Lifecycle.java http://jenkins-ci.org/commit/jenkins/b06e2aa3414d480d8b44459b0632226921be85f6 Log: [FIXED JENKINS-23683] Check whether war's directory is writable

          Code changed in jenkins
          User: Oleg Nenashev
          Path:
          core/src/main/java/hudson/lifecycle/Lifecycle.java
          http://jenkins-ci.org/commit/jenkins/773144f0a1f786f50086bac6e3af65380ceff9fb
          Log:
          Merge pull request #1311 from daniel-beck/JENKINS-23683

          [FIXED JENKINS-23683] Check whether war's directory is writable

          Compare: https://github.com/jenkinsci/jenkins/compare/ca53100caea7...773144f0a1f7

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oleg Nenashev Path: core/src/main/java/hudson/lifecycle/Lifecycle.java http://jenkins-ci.org/commit/jenkins/773144f0a1f786f50086bac6e3af65380ceff9fb Log: Merge pull request #1311 from daniel-beck/ JENKINS-23683 [FIXED JENKINS-23683] Check whether war's directory is writable Compare: https://github.com/jenkinsci/jenkins/compare/ca53100caea7...773144f0a1f7

          dogfood added a comment -

          Integrated in jenkins_main_trunk #3499
          [FIXED JENKINS-23683] Check whether war's directory is writable (Revision b06e2aa3414d480d8b44459b0632226921be85f6)

          Result = SUCCESS
          daniel-beck : b06e2aa3414d480d8b44459b0632226921be85f6
          Files :

          • core/src/main/java/hudson/lifecycle/Lifecycle.java

          dogfood added a comment - Integrated in jenkins_main_trunk #3499 [FIXED JENKINS-23683] Check whether war's directory is writable (Revision b06e2aa3414d480d8b44459b0632226921be85f6) Result = SUCCESS daniel-beck : b06e2aa3414d480d8b44459b0632226921be85f6 Files : core/src/main/java/hudson/lifecycle/Lifecycle.java

          Code changed in jenkins
          User: Daniel Beck
          Path:
          core/src/main/java/hudson/lifecycle/Lifecycle.java
          http://jenkins-ci.org/commit/jenkins/2f718f4d1fbdc4147f590731de2d52f184241d88
          Log:
          [FIXED JENKINS-23683] Check whether war's directory is writable

          (cherry picked from commit b06e2aa3414d480d8b44459b0632226921be85f6)

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Daniel Beck Path: core/src/main/java/hudson/lifecycle/Lifecycle.java http://jenkins-ci.org/commit/jenkins/2f718f4d1fbdc4147f590731de2d52f184241d88 Log: [FIXED JENKINS-23683] Check whether war's directory is writable (cherry picked from commit b06e2aa3414d480d8b44459b0632226921be85f6)

            danielbeck Daniel Beck
            danielbeck Daniel Beck
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: