You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Linux Mint 18.3下Jenkins主目录修改无效问题求助

Fixing Jenkins Home Directory Not Updating on Linux Mint 18.3

Hey there! Let's break down why your attempt to change JENKINS_HOME via the .profile file didn't work, and how to fix it properly.

The Root Cause

Jenkins runs as a system service on most Linux distros (including Mint 18.3), not as a regular user process. System services don't load user-specific shell configuration files like .profile—those only get read when you log into an interactive shell (e.g., opening a terminal or SSHing in). So your export line in .profile never gets picked up by the Jenkins service.

Step 1: Verify Jenkins' Startup Method

First, check if Jenkins uses systemd or upstart (Mint 18.3 is based on Ubuntu 16.04, which defaults to upstart, but some setups might use systemd):

  • Run systemctl status jenkins—if it shows "active (running)", you're using systemd.
  • If that returns an error, run sudo service jenkins status—if it works, you're using upstart.

Step 2: Update the Service Configuration

Choose the section below that matches your startup method:

Option A: For Systemd

  1. Stop Jenkins first:
    sudo systemctl stop jenkins
    
  2. Create an override file (safer than editing the main service file directly):
    sudo systemctl edit jenkins
    
  3. In the text editor that opens, paste this content:
    [Service]
    Environment="JENKINS_HOME=/home/alex/JenkinsHome/"
    
  4. Save and exit the editor.
  5. Reload systemd to apply the changes:
    sudo systemctl daemon-reload
    
  6. Start Jenkins back up:
    sudo systemctl start jenkins
    

Option B: For Upstart

  1. Stop Jenkins:
    sudo service jenkins stop
    
  2. Edit the upstart configuration file:
    sudo nano /etc/init/jenkins.conf
    
  3. Look for a line starting with env JENKINS_HOME=. If you find it, replace the path with /home/alex/JenkinsHome/. If not, add this line near the top of the file:
    env JENKINS_HOME=/home/alex/JenkinsHome/
    
  4. Save the file (Ctrl+O, then Enter) and exit nano (Ctrl+X).
  5. Start Jenkins again:
    sudo service jenkins start
    

Step 3: Fix Directory Permissions

Jenkins runs under the jenkins system user, so your new home directory needs the right permissions for it to read/write data:

sudo chown -R jenkins:jenkins /home/alex/JenkinsHome/
sudo chmod -R 755 /home/alex/JenkinsHome/

Step 4: Verify the Change

To confirm Jenkins is using the new home directory:

  • Check the Jenkins logs:
    • For systemd: journalctl -u jenkins | grep JENKINS_HOME
    • For upstart: cat /var/log/jenkins/jenkins.log | grep JENKINS_HOME
  • Or inspect the process environment variables:
    cat /proc/$(pgrep jenkins)/environ | tr '\0' '\n' | grep JENKINS_HOME
    

Quick Note on Your Initial Copy

Make sure you copied the original Jenkins data with permissions preserved. If you used a regular cp command, re-copy it with:

sudo cp -a /var/lib/jenkins/* /home/alex/JenkinsHome/

The -a flag preserves ownership, permissions, and symbolic links—critical for Jenkins to work correctly with the copied data.

内容的提问来源于stack exchange,提问作者OleksandrP

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 04:10:06