Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing the output of a job in Jenkins to another job

Tags:

jenkins

I made quite the research on this but couldn't find a satisfying answer. The following process will be automatic, repeating every night so no parameters could be passed in manually by the user at runtime. Parent job calls all the following subprocesses in a blocking chain My job hierarchy is set up like this with following main jobs and subprocesses:

Run-Tests-EveryNight (Parent Job)--> Create-A-Virtual-Machiene --> Run-Tests-On-VM

Moving on, when you create a VM it gets assigned a generated IP address, I need to pass in that IP address to Run-Tests-On-VM as a parameter but I can not seem to find any way to do it.

Clarification: Some people found the question unclear so: I am asking how to pass in the dynamically created IP address of a Virtual Machine as a PARAMETER to a different job (a subprocess)

NOTE: I have read about copying artifacts but I feel like it doesnt work in this case (plus writing and then reading from a file is way too much work for a simple parameter passing.)

I feel like there should be a really easy way to do this...

UPDATE: The use of Parameterized Trigger Plugin was suggested. I am already using and have the following bash script to copy the properties

# Create override properties file for functional tests
FILENAME="user.properties"
cd "path of the file goes here"
rm -f $FILENAME
echo "FQDN=$VM_FQDN" >> $FILENAME

However I do not know how to write into this file (or create a new properties file, to save the IP address as a post-build action

Answer: Following the answer below, use either of these threads to modify the properties file or use inject option in Jenkins Archive the artifacts in hudson/jenkins

How can I change a .properties file in maven depending on my profile?

Thanks

like image 496
sinanspd Avatar asked Sep 03 '15 16:09

sinanspd


1 Answers

Use Parametrized Trigger Plugin as mentioned Christopher, but with the option called Parameters from properties file.

The file has a simple key=value structure, you can create it during the job execution, save there the IP adress and use it later to pass it to the next job. I generally store the file somewhere in the build workspace, so parallel builds are handled seamlessly.

like image 125
l__j Avatar answered Sep 22 '22 07:09

l__j