Change limit nomber of open files

when I am running a gradle job on jenkins ( linux ubuntu 22.04), I get Error: EMFILE: too many open files,

the problem is
ulimit -n
4096
ulimit -s
8192

I tried to change these values from
/etc/security/limits.conf

  • soft nproc unlimited
  • hard nproc unlimited
  • soft nofile 65536
  • hard nofile 65536

Since I have last jenkins version 2.346.2 , I read I need to add
LimitNOFILE=65536
to
systemctl edit jenkins

but i still get ulimit 4096 in jenkins job, any idea what is the problem please