2017-06-26 9 views
0

を介してファイルを削除するとき、私はいくつかを削除しようhost.I Linux上ジェンキンスサーバーを持っていますジェンキンスdashboard.myパイプラインスクリプトからジェンキンスパイプラインを使用してファイルがfollwingのように行く:私はこのスクリプトを実行すると「java.nio.file.AccessDeniedException:/home/jenkins/workspace/testCases/41/1/1.in」ジェンキンスパイプライン

node(){ 
     int deleteCount=0 
     while(deleteCount < 10) 
     { 
     try{ 
      deleteCount++ 
      sh script:'rm -rf ../testCases/41/*' 
      boolean fileExist = fileExists '../testCases/41/1/1.in' 
      if(!fileExist) break 
     }catch(err) 
     { 
      sleep 1 
     } 
} 
writeFile file: '../testCases/41/1/1.in', text: 'bookstore' 
writeFile file: '../testCases/41/1/1.out', text: 'databaseName:bookstore' 
writeFile file: '../testCases/41/1/1.isPublic', text: '1' 
writeFile file: '../testCases/41/1/2.in', text: 'bookstore2' 
writeFile file: '../testCases/41/1/2.out', text: 'databaseName:bookstore2' 
writeFile file: '../testCases/41/1/2.isPublic', text: '1' 
writeFile file: '../testCases/41/2/1.in', text: 'book\n5\nid int(11)\nauthor 
varchar(255)\ntitle varchar(255)\npublisher varchar(255)\npublihserYear 
int(11)' 
writeFile file: '../testCases/41/2/1.out', text: 'table:book' 
writeFile file: '../testCases/41/2/1.isPublic', text: '1' 
writeFile file: '../testCases/41/2/2.in', text: 'book2\n3\nid int(11)\ntitle 
varchar(255)\nprice int(11)' 
writeFile file: '../testCases/41/2/2.out', text: 'table:book2' 
writeFile file: '../testCases/41/2/2.isPublic', text: '1' 
........ 

は、それが時にはそれが正常に完了し、時には失敗することができることが判明し、エラーログには、次のとおりです。

1 
+ rm -rf ../testCases/41 
rm: can't remove '../testCases/41/1/1.in': Permission denied 
rm: can't remove '../testCases/41/1/1.out': Permission denied 
rm: can't remove '../testCases/41/1/1.isPublic': Permission denied 
rm: can't remove '../testCases/41/1/2.in': Permission denied 
rm: can't remove '../testCases/41/1/2.out': Permission denied 
rm: can't remove '../testCases/41/1/2.isPublic': Permission denied 
rm: can't remove '../testCases/41/1': Permission denied 
rm: can't remove '../testCases/41/2/1.in': Permission denied 
rm: can't remove '../testCases/41/2/1.out': Permission denied 
rm: can't remove '../testCases/41/2/1.isPublic': Permission denied 
rm: can't remove '../testCases/41/2/2.in': Permission denied 
rm: can't remove '../testCases/41/2/2.out': Permission denied 
rm: can't remove '../testCases/41/2/2.isPublic': Permission denied 
rm: can't remove '../testCases/41/2': Permission denied 
rm: can't remove '../testCases/41/3/1.in': Permission denied 
.......`1` 


[Pipeline] sleep 
Sleeping for 1 sec 
[Pipeline] writeFile 
[Pipeline] } 
[Pipeline] // node 
[Pipeline] End of Pipeline 
java.nio.file.AccessDeniedException: 
/home/jenkins/workspace/testCases/41/1/1.in 
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84) 
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102) 
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107) 
atsun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.ja 
va:214) 
..... 
at hudson.FilePath$37.invoke(FilePath.java:1912) 
at hudson.FilePath$37.invoke(FilePath.java:1908) 
at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2739) 
at hudson.remoting.UserRequest.perform(UserRequest.java:153) 
at hudson.remoting.UserRequest.perform(UserRequest.java:50) 
at hudson.remoting.Request$2.run(Request.java:336) 
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68) 
at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
at hudson.remoting.Engine$1$1.run(Engine.java:94) 
at java.lang.Thread.run(Thread.java:745) 
at ......remote call to Channel to /10.9.186.111(Native Method) 
at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1545) 
at hudson.remoting.UserResponse.retrieve(UserRequest.java:253) 
at hudson.remoting.Channel.call(Channel.java:830) 
at hudson.FilePath.act(FilePath.java:986) 
Caused: java.io.IOException: remote file operation failed: /home/jenkins/workspace/testCases/41/1/1.in at [email protected]:Channel to /10.9.186.111 
at hudson.FilePath.act(FilePath.java:993) 
at hudson.FilePath.act(FilePath.java:975) 
at hudson.FilePath.write(FilePath.java:1908) 
at org.jenkinsci.plugins.workflow.steps.WriteFileStep$Execution.run(WriteFileStep.java:94) 
at org.jenkinsci.plugins.workflow.steps.WriteFileStep$Execution.run(WriteFileStep.java:84) 
at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution$1$1.call(SynchronousNonBlockingStepExecution.java:49) 
at hudson.security.ACL.impersonate(ACL.java:260) 
at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution$1.run(SynchronousNonBlockingStepExecution.java:46) 
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 
at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
at java.lang.Thread.run(Thread.java:748) 
Finished: FAILURE 

新しいデータを書き込む前に古いファイルを削除したいだけですが、この問題は仲間は私を混乱させる。拒否された

答えて

0

許可は、あなたはおそらく、あなたが彼らの所有者ではありませんが、そのフォルダ上の権利を持っている「ドン意味しますか? rootとしてコマンドを実行できますか?

+0

はい、私はrootでjenkinsを起動し、すべてのファイルに777のpermissions.sometingsを与えました。ファイルを正常に削除できますが、時にはできません –

0

Jenkinsにはこれらのファイルに対する権利がないことは明らかです。 一時的にrootユーザーで実行してjenkinsをテストしたところ、この問題に直面しました。ジェンキンス設定ファイルへ

ゴー(Red Hatの - の/ etc /のsysconfig /ジェンキンス)、そしてあなたはジェンキンスを実行するために使用しているユーザーを参照)。削除できないファイルは他のユーザーに属している可能性があります。

適切なユーザに手動でこれらのファイルを削除して、あなたは良いことがあります。

-1

私はマスターノードでビルドを実行すると、ジェンキンスはそのスレーブ(実際にはkubernetesポッド)にタスクを配布します。しかし、タスクはユーザー "jenkins"と一緒にポッドで実行されました。 "許可が拒否されました"

+1

何をしましたか? – shawn1874

関連する問題