Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins - Using the results of one job, in another job

Tags:

jenkins

ant

ivy

I have a job that runs a makefile and generates some files. I then want another job that publishes these files to ivy.

I am aware of the clone workspace plugin, but is there any other options?

like image 751
Dominic Bou-Samra Avatar asked Sep 28 '11 01:09

Dominic Bou-Samra


People also ask

How can you pass parameters from one job to another job in Jenkins?

You can use Parameterized Trigger Plugin which will let you pass parameters from one task to another. You need also add this parameter you passed from upstream in downstream.

How does Jenkins trigger jobs from other jobs?

You can follow the below steps to trigger a Jenkins pipeline in another Jenkins pipeline. Select a job that triggers a remote one and then go to Job Configuration > Build section > Add Build Step > Trigger builds on remote/local projects option.

Can we run parallel jobs in Jenkins?

In Jenkins, there are several ways to implement parallel job execution. One of the common approaches is the parent-child build model. In this model - a parent (upstream) job is triggering child (downstream) jobs.


2 Answers

You run a Makefile, and you're publishing to Ivy?

Ivy is part of Ant, and is a module that takes advantage of the worldwide Maven repository structure to grab required jarfiles and other dependencies.

Don't get me wrong, I've used a local remote Maven repository to publish C/C++ libraries (you can use wget to fetch the items) that other projects will depend upon. But, I didn't do that using Ivy.

If you're thinking of Apache Ivy, then you can publish using Maven. There's a Maven Release plugin that will copy your artifact to your Maven repository, but what you probably want to do is deploy.

In my Jenkins builds, I simply had Jenkins execute maven's deploy-file step from the command line. This allowed me to deploy files into my Maven Ivy repository without having to first create a pom.xml file. (Well, you want to create a pom.xml anyway because you want to include a dependency hierarchy.)

I usually did this in the same job as the job that created my jar/war/ear file. However, if you want a separate job to do this, you can use the Copy Artifact Plugin. This plugin allows Job B to copy any or all of the published artifacts from Job A. That's a lot faster and simpler than cloning a whole workspace if you just want the built jar files.

like image 103
David W. Avatar answered Sep 23 '22 06:09

David W.


My personal preference is to do these sort of things without relying on the Jenkins internal file structure, though sometimes this mean knowing about the internal structure of your other build tools (e.g., Maven, or in your case Ivy).

If I were you, I'd do everything in one job - i.e., build, and then have an "Ivy Publisher" (if such a plug in exists) publish the artifact to the remote Ivy repository.

If that's not possible, have the first job "install" the artifact into the local repository/cache (I'm not sure what it's called on Ivy), and then have the second job pick it up from there.

I'm not sure this is necessarily the best approach, but it has worked well for me.

Edit I should mention - this doesn't work so well on distributed environments, unless like me, your distributed environment consists of multiple nodes that have access to a common NAS filesystem.

Edit 2 I have also used the Copy To Slave Plugin for distributed environments without a common filesystem.

like image 35
Jack Leow Avatar answered Sep 21 '22 06:09

Jack Leow