Jenkins Permission Denied

2019-08-13 15:23发布

问题:

I'm sorry to come here and ask for that but I have read all the internet trying to find a solution but I still have this problem...

I have installed successfully (let's start when I still had hope) jenkins to use it in our continous integration flow.

I tried to start with a simple example like this one :

pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                sh 'mvn -B -DskipTests clean package' 
            }
        }
    }
}

But each time I start it, I have this error :

sh: /var/lib/jenkins/workspace/Test@tmp/durable-f70a79f3/script.sh: Permission denied

The problem is that user jenkins (service and the master node are running as Jenkins) have all the permissions on this repository. I tried to give group and others permissions to read and execute too but it doesn't change anything.

[centos@jenkins workspace]$ ll
total 8
drwxr-xr-x 2 jenkins jenkins 4096 Dec  8 18:35 Test
drwxr-xr-x 2 jenkins jenkins 4096 Dec 11 16:40 Test@tmp

We are launching jenkins with those parameters :

 -Djava.awt.headless=true -Djenkins.install.runSetupWizard=false -Djava.io.tmpdir=/var/lib/jenkins/tmp

and on a /jenkins url. Other than that, I don't see what could be the cause of the problem...

edit : Mounted volumes with noexec

sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_prio,net_cls)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)
/dev/mapper/rootvg-var_lv on /var type ext4 (rw,nodev,noexec,relatime,nobarrier,data=ordered)

Thanks a lot for your help.

回答1:

It was indeed the /var with noexec... I didn't thought all /var was in noexec. I read 10 times this line without even trying to change it... Thank you for your help

Solution : Like I said in comments, it was this line :

/dev/mapper/rootvg-var_lv on **/var** type ext4 (rw,nodev,**noexec**,relatime,nobarrier,data=ordered)

So I used sudo mount -o remount,exec /var and it's working fine now.