How to change default permissions on Jenkins workspace directory on fedora? - linux

I have a mysql instance that needs to dump csv files into a jenkins workspace. Unfortunately, Jenkins has permissions 755 for the workspace directory, and I need to be able to create and delete jobs of this type very often, so manual configuration doesn't work. How do I change the default permissions on these directories without writing a script do do it?

Just change the permissions on the root workspace directory. The workspaces for each job will be in subdirectories underneath the root, so they will inherit the root directory's permissions.
chown -R jenkins_user:jenkins_group /path_to_workspace_root

Related

GCP Filestore error modifying shared folder contents with nodejs script under non-root user

I want to write a program that writes log files into the shared folder in a GCP compute engine. I used GCP filestore to mount the NFS folder in an ubuntu vm. After creating the folder, I noticed that I couldn't use cp to copy file to that folder unless I use sudo. When I ran the nodejs script, it also returned a permission denied error. However, I don't want to run the nodejs script with root. Is there a way to modify the set of permission so that I can write to the shared folder under the default, non-root user?
I modified the permission of the shared folder to 777 but it didn't work. I still cannot write to the folder.

How to change the Jenkins Home Directory from /var/lib to app and create a symlink for orginal location as job wont get affected

I need to change my Jenkins 2.89.3 version Home Directory from /Var/lib/jenkins to /app due to space constraints. I need to make sure , all jobs which are using the /var/lib/jenkins directory wont get affected by this migration. how to perform this operation and ran my jenkins job as expected
Current size of /var/lib/jenkins 5.1G
Move all contents to /app/
run jenkins jobs without any issues
Please help in this migration
You can use a symbolic link to do that:
Shutdown you Jenkins.
Move all files from /var/lib/jenkins to /app/jenkins
mv /var/lib/jenkins /app/
Replace /var/lib/jenkins with a symbolic link to /app/jenkins
ln -s /app/jenkins /var/lib/jenkins
Start Jenkins again.
That way all the files are actually stored under /app but all paths to /var/lib/jenkins stay valid due to the symbolic link.

Laravel folder permission for not-yet made cache folders

I'm having an issue with directory permissions with Laravel when it comes to caching. Whenever it tries to upload a cache file to /var/www/laravel/storage/framework/cache/data/ it tells me that file_put_contents has no permissions.
To fix this I always do something like chmod -R 755 /var/www/laravel/storage/framework/cache/ but the problem here is that when it creates a new directory inside cache it does not inherit these chmod settings, thus giving me permission denied error again.
How can this be fixed permanently?
Edit:
Been thinking about letting it run as a cronjob regularly, but I'm not so sure that's a good way to deal with it.
You need to run chmod command with -R:
sudo chmod -R 755 storage
After installing Laravel, you may need to configure some permissions. Directories within the storage and the bootstrap/cache directories should be writable by your web server or Laravel will not run. If you are using the Homestead virtual machine, these permissions should already be set.
https://laravel.com/docs/5.5#installation

"Unable to create home directory" error when changing JENKINS_HOME

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).
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.
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
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

Linux: Allow one user to manage all files from another user/group

I just installed lamp-server^ on my home linux machine.
Now I created a new folder project with files in the /var/www/ directory (server root directory). I set the owner user/group to www-data via sudo.
Now I want to access the folder and its files via cd or normally via the file explorer, but I get the error that I haven't the permission to do/access that folder or its files (with my normal user account).
Is it possible to give my user account the rights to access/modify the project folder?
you can either
a+rwx the directory or
include yourself in that group, but from your question, it seems you don't want to do that. it would be more secure than allowing anyone to read, write and execute that dir.
Yes it is possible. Just add your user in www-data group.
useradd -G www-data {your_username}

Resources