How do I capture output from one Rundeck step to be used in a later step?

孤街醉人 提交于 2019-12-01 21:05:35

There is no direct Rundeck implementation that allows you pass an output from one job to another job as an input, but there are work around I've tried in the past, and I've settled on the second approach.

1. Use a file to pass data

  1. Save the ID/output into a tmp file in first job
  2. Second job read that file

Things might go wrong since you depend on a file, but good code can improve.

2. Call two jobs using Rundeck CLI from another job

This is the approach I am using.

JobA printout two random numbers.

echo $RANDOM;echo $RANDOM

JobB print out the second random produced from JobA which is passed as an option "number"

echo "$RD_OPTION_NUMBER is the number JobB received"

JobC calls first job, save last line to a variable and pass it to JobB

#!/bin/bash
OUTPUT_FROM_JOB_A=`run -f --id <ID of JobA> | tail -n 1`
run -f --id <ID of JobB> -- -number $OUTPUT_FROM_JOB_A

Output:

[5394] execution status: succeeded
Job execution started:
[5395] JobB <https://hostname:4443/project/Project/execution/show/5395>
6186 is the number JobB received
[5395] execution status: succeeded

This is just primitive code sample. you can do alot with python subprocess or just use bash.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!