where did the workspace go in jenkins pipelines

I was encountering an odd problem and needed to see what files were in a Jenkins workspace. For a freestyle job, this is easy; you just click on “workspace.”

workspace-freestyle

Where did it go?

When using a pipeline, you can have multiple nodes in your pipeline so it isn’t that simple. As described in JENKINS-33839, this means you need to click around to get to it. While I did find it, this isn’t something I do often enough to remember so writing it up for my future self and anyone else who happens to read this. (Right after I wrote this, I saw JENKINS-34321 which does explain the steps well. Mine has pictures so might as well leave it.)

  1. First, go to the build run you are interested in and click “pipeline steps”.
    pipeline-1
  2. The click “allocate node: start”. If you have multiple nodes, you’ll need to do this more than once.
    pipeline-2
  3. Then you click the workspace link.
    pipeline-3

 

Implication #1 – wipe out workspace is gone

Since the workspace is no longer tied to the job, there’s also no “wipe out workspace” option. If you need to delete the workspace, you need to delete the entire run of the job. (Maybe someone had something in the build that they shouldn’t and you want it gone.) Ok. No big deal. You have to delete a bit more than before, but it isn’t as if it is something you need for posterity.

Implication #2 – multiple “workspaces”

Since you get to the workspace from within the build, I thought this meant there were multiple. And I was afraid for the disk space. Luckily, that is not the case. Within the same node, each build does re-use the same workspace. So if you go to an old build and look at the “workspace”, it is the workspace from the latest run. Which isn’t intuitive, but I’m glad it works that way.

8 thoughts on “where did the workspace go in jenkins pipelines

  1. thanks!

    on disk the workspace is now in ~jenkins/workspace, rather than buried under jobs. but there’s more than one per job now, which means you have to work out which one belonged to that build

  2. That info is not completely correct, you can use step([$class: ‘WsCleanup’]) in your pipeline to clean the workspace automatically

  3. @gsnerf: True. I don’t want to clean the workspace automatically though. I want to do it on demand manually like I used to be able to. That way the workspace is there after for review, but I can clean it out as needed

  4. @Jeanne Boyarsky but you absolutely can, go into the last build, hit replay, replace pipeline with cleanWs(), run once.

  5. @hyos: I’m a novice, so following your advice, I just replaced the whole script with one line containing the cleanWs() or deleteDir(). That didn’t work. Could you please show a complete example as it should be in the pipeline edit box?

  6. Pingback: How to view Jenkins workspace on a Pipeline job? – Config9.com

  7. A critical step is to click on an ‘allocate node: start’ link. The author does include this, but I glossed over it. I clicked on the link where my build failed; which seems like the right choice to me. But there is no workspace link under that. The workspace link is only on the ‘allocate node: start’ page.

    Further, as hinted by “If you have multiple nodes, you’ll need to do this more than once” you need to choose the right allocate link or try each one to find the one you want. I assume you want the link that is at the top of the hierarchy for the step that failed.

Leave a Reply

Your email address will not be published. Required fields are marked *