Parsing data between Jenkins Jobs

Yasassri Ratnayake
1 min readMay 20, 2019

Jenkins is the most widely used CICD/Build tool that’s being used for many software projects. The stability and the extensibility of Jenkins has made it the number one go to tool when doing CICD work.

In this post I will explain how you can parse some information from one build to the next build. My use case was, I was creating docker images with a build pipeline to update an environment and after updating a environment if something goes wrong in the environment the user has the ability to revert the environment. So inorder to rever the environment the build pipeline had to know the currently deployed versions.

This could be simply done with some groovy code. In this case I was using Env Inject plugin and I updated the Environment variable with the information I needed for the next job and this env variable was read by the next Job. Following is the simple groovy code you can use for this.

What the above will do is read the existing environment variables and add a new environment variable called UPDATED_DOCKER_IMAGES. This property can be read from the next build.

Hope this helps someone in need. Please drop a comment if you have any queries.

--

--