views:

1857

answers:

5

Our organization's custom build tools write out a lot of intermediate data, and I'd like it if Hudson could detect which files were created as part of a build and archive those. I'm not sure if it already does so, but if it does there's no user-visible explanation of it, and certainly deleting a build does not delete its output.

In detail here's what I want. Suppose I start with a bare workspace. After build 1, I have this:

ws/
  src/...
  obj/
    1/...
  log/
    1/...
  pkg/
    pkg-1.tgz

Now, I run build 2:

ws/
  src/...
  obj/
    1/...
    2/...
  log/
    1/..
    2/..
  pkg/
    pkg-1.tgz
    pkg-2.tgz

The source code is checked out into ws/src each build; there's a custom checkout process, so I can't use the svn RCS method :/.

When I delete a build, I'd like to delete everything that came from that build. Can I do this?

A: 

It's difficult to answer without understanding your "custom checkout process", but typically all of the project's build artifacts are created beneath a single directory apart from the src, e.g. "build" or "target".

That way, the project's "clean" target can simply remove that directory, and you can instruct Hudson to include this target for each build.

It appears your build artifacts are contained in multiple directories relative to 'src': 'obj', 'log', and 'pkg'. Can you introduce a "clean" target that will explicitly delete each of those directories?

jcrossley3
I can, but how can I get Hudson to run that when I delete a job?
Chris R
I misunderstood your question. I was thinking you could just add "clean" to your build targets and essentially keep only one version (the latest) of the artifacts. Perhaps the "Use custom workspace" advanced option is of use?
jcrossley3
+1  A: 

What I would do, if I were in your shoes, would be to solve the problem a different way. I would write a task or script that specifically deletes everything you don't want to keep, and run that task or script at the end of each job.

Hudson assumes you're cleaning up temp files on your own. If that's not happening, I don't believe Hudson has any facility to help you.

johnbr
A: 

Why do you need tgz archive making at every build triggering?

When I delete a build, I'd like to delete everything that came from that build. Can I do this?

Extract build number to system/build tool's variable, and 3 simple UNIX shell commands: * 2 for directories delete in obj and log * one for package delete by mask(need to inject variable's value)

Fedyashev Nikita
+2  A: 

The Hudson way would be to clean up all temporary files at the beginning of the build, and then use Hudson's artifacts archive facility to save the output from each build - specify pkg/*/.tgz for the "Archive the Artifacts" post build step and then the tgz files will all be copied into the job specific storage area.

The workspace is just a workspace - it's not intended for long term storage.

Michael Donohue
A: 

Use this: http://stackoverflow.com/questions/805909/how-can-i-delete-hudsons-built-artifacts

inakiabt
The OP's question is about deleting the artifacts that live in the workspace and were created by the build script, not the artifacts that Hudson has stored using the "Archive Artifacts" post build action.
Michael Donohue