How do I purge/clobber stashed files?

jenkins jenkins-plugins jenkins-pipeline

586 观看

1回复

5931 作者的声誉

Jenkins docs seem ambiguous about this:

Stashed files are not otherwise available and are generally discarded at the end of the build.

Soooo "generally" means what? They should get discarded by default? Do I need to do something to have them discarded?

Because my stashed files aren't getting discarded. I run this:

stash name: "myZip", includes: "${differentEveryTime}.zip"

And every time the job runs it keeps adding the new zip file to the "myZip" stash.

I couldn't find anything in the docs about how to control this. I want myZip to clobber everything previously or start empty each job run.

At the start of my pipeline, in my first stage, I do this:

step([$class: 'WsCleanup'])
checkout scm

It seems to successfully cleanup my workspace. Where is the stash actually stored on the filesystem so i can confirm this?

EDIT: The accepted answer is correct, but for more clarity on my confusion: I wasn't cleaning up the work spaces of my parallel stages, just my main pipeline's workspace. The streams workspaces were persisting and contained the old files.

作者: red888 的来源 发布者: 2017 年 12 月 27 日

回应 1


1

24059 作者的声誉

决定

The reason why your stash contains files from older runs is most likely because all runs re-use the previous workspace - containing files from previous runs (that you include when creating the ZIP file?

Clean your workspace, e.g. using git clean -fdx at the beginning of the job, and your stashes should only include artifacts from the current run. At least it never happened to me that stashes created using the stash step accumulated files from previous runs.

作者: StephenKing 发布者: 2017 年 12 月 27 日
32x32