This guide provides the necessary steps to grant the GitLab Runner user the correct file system permissions to access project directories.
1. Grant Group Membership
To allow the GitLab Runner to access project files, you must add its dedicated user, gitlab-runner, to the same group as the project's owner (in this case, enlivendev).
-
Run the following command to add the runner to the group:Bash
sudo usermod -aG enlivendev gitlab-runner
2. Set Directory Permissions
Next, ensure the permissions on the project directory are set correctly to allow group access.
-
Set Ownership: Confirm the directory is owned by the user and group.Bash
sudo chown -R enlivendev:enlivendev /home/enlivendev -
Set Permissions: Apply
775permissions recursively. This allows the owner and group members (includinggitlab-runner) to read, write, and execute files, which is necessary for the runner to operate correctly.Bashsudo chmod -R 775 /home/enlivendev
3. Install and Start the Runner Service
If you haven't already, install the GitLab Runner as a systemd service and ensure it's running.
-
**Install the service:**Bash
sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner -
Enable and start the service: This ensures the runner starts automatically on boot.Bash
sudo systemctl enable gitlab-runner sudo systemctl start gitlab-runner
4. Verify the Setup
Finally, check that the runner service is active and properly connected to your GitLab instance.
-
**Check the service status:**Bash
sudo systemctl status gitlab-runner- Look for
Active: active (running)in the output.
- Look for
-
**Verify the connection to GitLab:**Bash
sudo gitlab-runner verify- The output should show that the runner is valid and connected.
Your GitLab Runner is now fully configured with the necessary permissions to access and manage files within the /home/enlivendev directory, ready to execute CI/CD jobs.