jenkins group while in job is not the same as in terminal

I have installed jenkins on our dev server, and I added the user "jenkins" to some groups for example www-data.

now when I run this command on the terminal:

groups jenkins

I get this output

jenkins www-data

and that is ok, but in one of my jobs I created an ssh command that simply does

groups jenkins

and the result is

jenkins

as you can see the "www-data" group is missing, so I have some permissions errors.

Any ideas why this weird bug happens??


Solution 1:

Your Jenkins runit setup may be using chpst to run as the jenkins user with only the jenkins group. Check your /etc/sv/jenkins/run, if it has exec chpst -u jenkins -U jenkins, change it to exec chpst -u jenkins:jenkins:www-data -U jenkins and restart