In Ubuntu, how do I change the home path of Jenkins using the CLI?



  • In the Jenkins web interface, under Home directory (Dashboard -> Mange Jenkins -> Configure System), the help section says the following:

    • "By default, Jenkins stores all of its data in this directory on the file system", referring to /var/lib/jenkins
    • "Edit the JENKINS_HOME variable in your Jenkins configuration file (e.g. /etc/sysconfig/jenkins on Red Hat Linux)"

    However, my etc directory doesn't have a directory called sysconfig.

    Running the following command returns a lot of files among which only the following seems relevant:

    find ~/ -type f -name "config.xml"
    
    /var/lib/jenkins/config.xml
    
    

    The file contains the following field:

    ${JENKINS_HOME}/workspace/${ITEM_FULL_NAME}
    

    Is this the correct field to edit? If so, which syntax should I follow while entering the desired path?



  • This question was already https://stackoverflow.com/questions/13192322/how-to-change-home-directory-of-jenkins on Stack Overflow. I'll copy the top answer here, but there are several other answers over there that you may find useful:

    For me on Jenkins 2.7.2 on RHEL 7.2 after already starting jenkins and configuring a build, I needed to:

    1. Change the jenkins user's home directory

      sudo su -
      service jenkins stop
      vi /etc/passwd
      #  change the /var/lib/jenkins to /home/jenkins or whatever 
      
    2. Change the setting in the start script to also find it

      vi /etc/sysconfig/jenkins
      #   change the JENKINS_HOME to /home/jenkins or what ever
      
    3. Copy all the data to the new location (eg: /home/jenkins)

      cd /home
      cp -Rf /var/lib/jenkins .
      chown -R jenkins:jenkins *
      
    4. Start it back up

      service jenkins start
      

    And that seems to have done it for me.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2