8

I am running Jenkins version 1.527 (I know there is a newer version but it is broken, I can't use the user interface in 1.528 and haven't gotten a chance to upgrade to 1.529)

I am trying to change the user.home system property in Jenkins by doing this in my startup script:

export HOME=/new-home-dir

However, the environment variable shows correctly in jenkins and user.dir shows as the exported variable, but user.home does not change.

The reason I can't use the default functionality is because I am in an enterprise that locks down the user's home directory and my user can add or modify files there.

Any help on changing user.home would be greatly appreciated.

FYI - I am running Jenkins on RHEL v6.2

Attempted Solutions

  1. add -Duser.home=/newDir to JAVA_OPTS or JAVA_ARGS, neither worked
  2. add -Duser.home=/newDir to the MAVEN_OPTS in the build job.
tshepang
  • 12,111
  • 21
  • 91
  • 136
TheDevOpsGuru
  • 1,570
  • 5
  • 21
  • 36
  • 1
    did you try over riding it in the user's .bash_profile See http://superuser.com/questions/183870/difference-between-bashrc-and-bash-profile ; http://stackoverflow.com/questions/4608187/how-to-reload-bash-profile-from-the-command-line and http://hacktux.com/bash/bashrc/bash_profile make sure you edit the correct file for your OS and shell. Can make sure by echo "am in file ..." in each – tgkprog Sep 10 '13 at 09:04
  • 1
    unfortunately, I do not have access to these files. I have made a request to an SA to add a home directory for the user, but I would still like to see an answer for this question since Jenkins should be picking up changes to the HOME environment variable. – TheDevOpsGuru Sep 10 '13 at 16:11
  • maybe you can try the jenkins support site? – tgkprog Sep 12 '13 at 17:15
  • already tried, doesn't seem to get too much attention as people that run jenkins must not be running it in the same type of restrictive environment that I am. – TheDevOpsGuru Sep 19 '13 at 14:55
  • oh well i guess the next thing to try is set a bounty for this question or to get the source code and fix your self or start process to get it updated (IF the new version supports that ) – tgkprog Sep 19 '13 at 15:58
  • It could be a permission problem that limits Jenkins with this specific folder. Did you already check it? – Pmt Oct 28 '13 at 18:02

5 Answers5

4

I found another workaroud.

  1. Go to the Manage Jenkins > Configure System
  2. Navigate to the Global Properties
  3. Make the Checkbox Environment variables active
  4. Name field pop up the user.home
  5. value is your desired path
  6. Click Apply, Save and Restart Jenkins

This overrides that path.

Michal
  • 610
  • 10
  • 24
3

I exactly had the same problem. You cannot just add an environment variable to change the path. You'll need to change the jenkins user's home directory itself.

In a linux/unix based system run the following command on your terminal.

login as a root user or use sudo in front of the commands if you're not running it as root user,

1) Move the Jenkins installation directory your desired location.

  mv /var/lib/jenkins /path/to/your/location

2) Change the Jenkins users home directory.

  usermod -d /path/to/your/location jenkins

Now restart jenkins. You should see the user.home and HOME variable set to the new location.

Dinesh
  • 1,711
  • 2
  • 20
  • 41
1

I had the same problem and solved in two different ways:

1- At the first time I edited the file startup.sh, inside /tomcat/bin. Inside this file I added this at the first line: JENKINS_HOME=/var/jenkins

2- Set the same inside environment variables. Just take care to set the variable with the same user that Jenkins are executed. For example, if Jenkings Jenkins is running under root, you need to specify the environment variable with this uses.

Observation: Because of compatibility questions, if you define HUDSON_HOME instead of JENKINS_HOME it will works fine two.

Hope it helps!

Pmt
  • 1,122
  • 3
  • 13
  • 27
1

I exactly had a same problem on ubuntu server.

login as a root user.

stop the all process running with a jenkins user.

1) stop the jenkins service.

  sudo service jenkins stop

2) Change the Jenkins users home directory.

  usermod -d /path/to/your/location jenkins

3) start the jenkins service.

  sudo service jenkins start 

You will see the user.home and HOME and PWD variable set to the new location.

  • Go to: Manage Jenkins > system information

  • Here you will see the changed variables location

Mr.K
  • 13
  • 4
0

Changing JENKINS_HOME and user.home are two separate topics. The original questions is all about changing the user.home system property. I resolved this issue (in Jenkins 2.34) by following the steps mentioned below:

  • Go to: Manage Jenkins > Configure System
  • Check the 'Environment variables' checkbox
  • Enter 'user.home' in Name field and your desired user home path in Value field
  • Save the changes and you are done In my Jenkins, I was facing the issue that Jenkins maven was trying to read the maven settings.xml from a wrong user.home path. I resolved this issue by adding 'user.home' environment variable in Jenkins as explained above.
Rajib Biswas
  • 772
  • 10
  • 27