Pipeline: stash includes with git directory

6,656 views
Skip to first unread message

Sverre Moe

unread,
Jun 16, 2016, 3:59:16 AM6/16/16
to Jenkins Users
I need the git directory stashed because I need git archive, which does not work unless the git repository is present.

I have tried several patterns, but been unsuccessful.
stash includes: '**', name: 'root'
stash includes: '**/*', name: 'root'
stash includes: '**/.*, **/*', name: 'root'
stash includes: '**/.git, **/*', name: 'root'

Sverre Moe

unread,
Jun 16, 2016, 8:25:41 AM6/16/16
to Jenkins Users
I found I could use useDefaultExcludes=false with stash

stash includes: '**/*', name: 'root', useDefaultExcludes: false

Will stash the entire git repository
However it fails after trying to unstash
java.io.IOException: remote file operation failed: /home/build/jenkins/workspace/projectA/master at hudson.remoting.Channel@67b96d99:master-sles11-x86_64: java.io.IOException: Failed to extract input stream
at hudson.FilePath.act(FilePath.java:1014)
at hudson.FilePath.act(FilePath.java:996)
at hudson.FilePath.untarFrom(FilePath.java:728)
at org.jenkinsci.plugins.workflow.flow.StashManager.unstash(StashManager.java:114)
at org.jenkinsci.plugins.workflow.support.steps.stash.UnstashStep$Execution.run(UnstashStep.java:64)
at org.jenkinsci.plugins.workflow.support.steps.stash.UnstashStep$Execution.run(UnstashStep.java:54)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:49)
at hudson.security.ACL.impersonate(ACL.java:213)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:47)
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:745)
Suppressed: java.io.IOException: remote file operation failed: /home/build/jenkins/workspace/projectA/master at hudson.remoting.Channel@5c465123:master-sles11-i686: java.io.IOException: Failed to extract input stream
... 14 more
Caused by: java.io.IOException: Failed to extract input stream
at hudson.FilePath.readFromTar(FilePath.java:2328)
at hudson.FilePath.access$400(FilePath.java:195)
at hudson.FilePath$10.invoke(FilePath.java:730)
at hudson.FilePath$10.invoke(FilePath.java:728)
at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2772)
at hudson.remoting.UserRequest.perform(UserRequest.java:152)
at hudson.remoting.UserRequest.perform(UserRequest.java:50)
at hudson.remoting.Request$2.run(Request.java:332)
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 java.lang.Thread.run(Thread.java:745)
at ......remote call to master-sles11-i686(Native Method)
at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1416)
at hudson.remoting.UserResponse.retrieve(UserRequest.java:252)
at hudson.remoting.Channel.call(Channel.java:781)
at hudson.FilePath.act(FilePath.java:1007)
... 13 more
Caused by: java.io.FileNotFoundException: /home/build/jenkins/workspace/projectA/master/.git/objects/pack/pack-dc9fd69196e6d0296658954add908b642e5b18f9.idx (Permission denied)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at java.io.FileOutputStream.<init>(FileOutputStream.java:162)
at hudson.util.IOUtils.copy(IOUtils.java:38)
at hudson.FilePath.readFromTar(FilePath.java:2318)
at hudson.FilePath.access$400(FilePath.java:195)
at hudson.FilePath$10.invoke(FilePath.java:730)
at hudson.FilePath$10.invoke(FilePath.java:728)
at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2772)
at hudson.remoting.UserRequest.perform(UserRequest.java:152)
at hudson.remoting.UserRequest.perform(UserRequest.java:50)
at hudson.remoting.Request$2.run(Request.java:332)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
... 4 more
Caused by: java.io.IOException: Failed to extract input stream
at hudson.FilePath.readFromTar(FilePath.java:2328)
at hudson.FilePath.access$400(FilePath.java:195)
at hudson.FilePath$10.invoke(FilePath.java:730)
at hudson.FilePath$10.invoke(FilePath.java:728)
at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2772)
at hudson.remoting.UserRequest.perform(UserRequest.java:152)
at hudson.remoting.UserRequest.perform(UserRequest.java:50)
at hudson.remoting.Request$2.run(Request.java:332)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
at ......remote call to master-sles11-x86_64(Native Method)
at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1416)
at hudson.remoting.UserResponse.retrieve(UserRequest.java:252)
at hudson.remoting.Channel.call(Channel.java:781)
at hudson.FilePath.act(FilePath.java:1007)
... 13 more
Caused by: java.io.FileNotFoundException: /home/build/jenkins/workspace/projectA/master/.git/objects/pack/pack-dc9fd69196e6d0296658954add908b642e5b18f9.idx (Permission denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
at java.io.FileOutputStream.<init>(FileOutputStream.java:171)
at hudson.util.IOUtils.copy(IOUtils.java:38)
at hudson.FilePath.readFromTar(FilePath.java:2318)
at hudson.FilePath.access$400(FilePath.java:195)
at hudson.FilePath$10.invoke(FilePath.java:730)
at hudson.FilePath$10.invoke(FilePath.java:728)
at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2772)
at hudson.remoting.UserRequest.perform(UserRequest.java:152)
at hudson.remoting.UserRequest.perform(UserRequest.java:50)
at hudson.remoting.Request$2.run(Request.java:332)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
... 1 more

Antonio Muñiz

unread,
Jun 21, 2016, 7:27:34 AM6/21/16
to jenkins...@googlegroups.com
This should work:

node {
    git 'your_repo_url'
    stash name: 'repo', useDefaultExcludes: false
}

node {
    ws {
        unstash 'repo'
        sh 'ls -la'
    }
}

The `ws` step is just to unstash in a clean directory, it's not really necessary.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/9bdbc5ab-e47f-4080-aa4e-69b76716b446%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Antonio Muñiz
Software Engineer
CloudBees, Inc.

Reply all
Reply to author
Forward
0 new messages