简体   繁体   中英

Jenkins - How to pass parameters from a downstream job to its parent upstream?

After cracking the reverse problem, I now need to pass some simple data back from each downstream job to its parent. One obvious option is to write the data to a file, save it as an artifact and then have the parent upstream job retrieve the artifacts of all its downstream jobs.

Any other idea? I have not seen any plugins for this and both the Build Pipeline and Workflow plugin seem to be overkill for this.

Thanks, Amir

The solution that I chose does not use any Jenkins mechanism, since there are none...
I ended up using RabbitMQ messaging queue, as follows:
1. Set up a persistent RabbitMQ server on a separate host (which is not connected to Jenkins). Host is CentOS 7.
2. Added a pub/sub subscriber in the upstream job.
3. Added a pub/sub publisher in the downstream job.

The upstream subscriber polls the message queue for messages published by the downstream job and acts upon receiving those message.

This has the added benefit that downstream jobs can inter-communicate via the same mechanism.
All scripts are in Python, so I am using pika to interact with RabbitMQ.
Pika: https://pika.readthedocs.org/en/latest/index.html

I am interesting in gathering more details about the context of such requirement... I am not convince by the effectiveness of job dependencies. You should consider the following algorithm.

A (manual event) execute B (forced event), then execute C (forced event)

and the other sequence (which shoulf match more with native Jenkins way of life)

A (manual event ) update artefact a, B ( artefact change surveil on a) is executed and update artefact b, C (artefact change surveil on a -or b if sequence required) is executed and update artefact c, D (other job artefact change surveil on b and c (or c if sequence B,C is required) is executed and finished the work.

Then you will focused on when does a job is started (triggering system - SCM event trigger, FStrigger, URLTrigger, IvyTrigger, ScriptTrigger) and what does a job is producing. (deployArtefact, promotedbuild, etc ...)

To manage variability you should also have a glance at Variable extractor plugin ( https://github.com/cittools/variables-extractor-plugin ) that implements a regular expression variable reader in the same syntax than Python named regexp wrapper.) Sometimes, it may be usefull.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM