我在 jenkins 中有一个奇怪的问题,我无法在作业中复制文件,但是,使用命令行上的用户 jenkins,我可以毫无问题地做到这一点。
我在用户“jenkins”下运行的 debian 上使用 jenkins。
我将用户“jenkins”添加到组“www-data”中,这样我就可以将文件复制到 apache 的 www 文件夹中。
目标文件夹的文件夹权限如下所示:
drwxrwxr-x 9 www-data www-data 4096 Jun 23 16:19 .   
drwxrwxr-x 4 www-data www-data 4096 Jun 23 12:45 ..  
-rw-rw-r-- 1 volker   www-data  368 Jun 23 17:10 about.php  
-rw-rw-r-- 1 volker   www-data  366 Jun 23 17:10 bio.php  
-rw-rw-r-- 1 volker   www-data  370 Jun 23 17:10 contact.php   
drwxrwxr-x 3 volker   www-data 4096 Jun 23 16:19 content  
drwxrwxr-x 3 volker   www-data 4096 Jun 23 16:19 css  
drwxrwxr-x 8 volker   www-data 4096 Jun 23 16:19 default  
drwxrwxr-x 3 volker   www-data 4096 Jun 23 16:19 fonts  
drwxrwxr-x 2 volker   www-data 4096 Jun 23 13:40 image  
drwxrwxr-x 3 volker   www-data 4096 Jun 23 16:19 images  
-rw-rw-r-- 1 volker   www-data  372 Jun 23 17:10 impressum.php  
-rw-rw-r-- 1 volker   www-data  367 Jun 23 17:10 index.php  
-rw-rw-r-- 1 volker   www-data  296 Jun 23 13:52 kontakt.php  
drwxrwxr-x 3 volker   www-data 4096 Jun 23 16:19 layout   
-rw-rw-r-- 1 volker   www-data  367 Jun 23 17:10 news.php  
-rw-rw-r-- 1 volker   www-data  370 Jun 23 17:10 termine.php  
-rw-rw-r-- 1 volker   www-data  369 Jun 23 17:10 videos.php  
所以对于组 www-data,一切都是可写的。
如果我使用 jenkins 用户复制 shell 中的文件,则不会出现错误:
jenkins@rootserver:~/jobs/deploy_notundellende/workspace$ whoami  
jenkins  
jenkins@rootserver:~/jobs/deploy_notundellende/workspace$ cp -R * /var/www/nue  
jenkins@rootserver:~/jobs/deploy_notundellende/workspace$   
但是,如果我在 jenkins 本身中使用相同的命令,它会因权限错误而失败:
pwd  
/var/lib/jenkins/jobs/deploy_notundellende/workspace  
whoami  
jenkins  
cp -R about.php bio.php contact.php content css fonts images impressum.php index.php   layout news.php termine.php videos.php /var/www/nue  
cp: cannot create regular file `/var/www/nue/about.php': Permission denied  
cp: cannot create regular file `/var/www/nue/bio.php': Permission denied  
cp: cannot create regular file `/var/www/nue/contact.php': Permission denied  
cp: cannot create regular file `/var/www/nue/content/videos.php': Permission denied  
这怎么可能?有人有想法吗?