Müller
Müller

Reputation: 1023

Keep this build forever option - Jenkins

I know there is a Keep this build forever button on Jenkins. I have a question with respect to this:

I have a configuration consisting of one main job and many sub-jobs (split across various phases). I would like to know if I click on the button in the main job, whether the artefacts in the sub-jobs are also stored permanently or not? Or should I go into each sub-job and keep clicking the button?

Upvotes: 4

Views: 11631

Answers (3)

Holi
Holi

Reputation: 384

It is enough in each of the (sub) job's pipeline or groovy script to write 'currentBuild.rawBuild.keepLog(true)'

Upvotes: 2

Harry G.
Harry G.

Reputation: 324

There is no out-of-the-box solution.
You need a custom System Groovy script for this.

E.g. we do it this way:

  • in our case, the main job copies artifacts from other jobs
  • it writes the job names and build numbers of the copied artifacts into a .json file
  • later we use this .json file in a System Groovy script to go through all jobs and set "keep forever" automatically

Upvotes: 0

Bruno Lavit
Bruno Lavit

Reputation: 10382

This option only affects the current job.

If you want to keep your artifacts and build information for all the sub-jobs, you have to click on the "keep this build forever" for each one.

Upvotes: 3

Related Questions