HiveBrain v1.2.0
Get Started
← Back to all entries
patterngitMinor

Pass information between Jenkins Job builds

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
buildspassjenkinsbetweenjobinformation

Problem

Please excuse my non-fluent terminology..

There is a Jenkins server, master and a few slaves, there is a pipeline job.. let's call it playground

I run the job once, I want to save some data somewhere.
Run the job again, I want to get the data from previous build.

  • Given that the Jenkins server is bounded to a VPN



  • Given that the Job may run on master or any of the slaves



  • Given that the Job deletes the workspace with every build



I couldn't find a way to save and load the data..

One plugin that actually do this is the git plugin, that saves the commit id and reads it in the next build for the changelog

I went through the git plugin code.. I am very confused and cannot figure out how or where it is done!

Can someone point me in the right direction.

Solution

There's a simple two step process...

In your originating job, tick step [ X ] Archive the artifacts and set the files to archive.

The files are copied to the master, stored in the jobs folder tree, under the builds directory for each build, along with the log. (Delete the build and it deletes the artifacts that came from it).

Install the Copy Artifact plugin.
Configure the job accordingly.

Despite the plugin's screenshot example, this is actually a bad practice for artifacts like jars. Those should be properly managed using an artifact repository like Nexus or JFrog.

See my response regarding keeping the the Jenkins space under control, managing the build and artifact retention soundly.

Context

StackExchange DevOps Q#12616, answer score: 3

Revisions (0)

No revisions yet.