4

Jenkins was running all fine on a RedHat Linux machine (a clean EC2 machine on AWS), until I decided to change the JENKINS_HOME. I simply moved the Jenkins directory from /var/lib/jenkins to /home/ec2-user/jenkins and then created a symlink. (I followed the first answer to this question: Change JENKINS_HOME on Red Hat Linux?).

However when I restart Jenkins I get the error:

Unable to create the home directory ‘/var/lib/jenkins’. This is most likely a permission problem. To change the home directory, use JENKINS_HOME environment variable or set the JENKINS_HOME system property.

I tried changing JENKINS_HOME in /etc/sysconfig/jenkins, setting it to the new folder (which I suppose defeats the point of a symlink?) and I still get the same error

Unable to create the home directory ‘/home/ec2-user/jenkins’.

It is for backup purposes, so that I have all Jenkins data in a mounted external data storage (AWS Elastic File System).

Community
  • 1
  • 1
ru111
  • 813
  • 3
  • 13
  • 27
  • You should answer your own question; see http://stackoverflow.com/help/self-answer Do not edit the answer into the question. – SiKing Jan 25 '17 at 16:18

3 Answers3

2

I've figured it out. This error was persisting because the /jenkins/ folder needs to be accessible to user 'jenkins' to run processes, but it couldn't access this folder because it is belongs to the particular logged in user. I changed the mounting to /var/ where jenkins can access as global process, and it solved the problem.

ru111
  • 813
  • 3
  • 13
  • 27
1

I ran into the same problem, so sharing my solution here:
The user jenkins does not have access to the folder home/ec2-user/jenkins. You can modify the access rights of the folder home/ec2-user/home by changing or adding the user jenkins to owner

sudo chown jenkins /home/ec2-user/jenkins
sudo chmod u+w /home/ec2-user/jenkins

To verify the new ownership, you can do:

ls -ld /home/ec2-user/jenkins
DerFaizio
  • 148
  • 7
0

The error seems pretty obvious: "This is most likely a permission problem."

I assume /home/jenkins does not exists, and the user jenkins does not have write permissions in /home. If you moved the Jenkins home, then you probably did it as root and just forgot to update owner permissions.

You would need to create the home, something like this:

sudo service jenkins stop
# make the changes in /etc/sysconfig/jenkins
sudo mkdir --parents /home/jenkins  # or mv, in your case
sudo chown --recursive jenkins /home/jenkins
sudo service jenkins start
SiKing
  • 10,003
  • 10
  • 39
  • 90
  • I moved the whole jenkins directory to /home/jenkins so it does exist. Nevertheless I've followed these commands word for word and it hasn't resolved the problem (same error message as before). – ru111 Jan 23 '17 at 12:32
  • @ru111 If you moved the Jenkins home, I am guessing you did it as root (or some other user). I updated my answer: You would need to pass recursive to the `chown` command. – SiKing Jan 23 '17 at 17:12
  • Thanks however the error is still there. I am thinking it may have something to do with permissions on the AWS elastic file system... – ru111 Jan 24 '17 at 12:07
  • @ru111 This is obviously a problem inside the machine. Once the machine is up and running, AWS filesystem is no longer involved ... for the most part. But I have no other alternative to offer. Sorry. – SiKing Jan 25 '17 at 00:50