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

前端 未结 1 488
逝去的感伤
逝去的感伤 2021-01-19 17:01

I\'m attempting to build, launch, and link a set of docker containers using Rundeck. In short (for those not familiar with docker), when an image is launched, it returns a

相关标签:
1条回答
  • 2021-01-19 17:37

    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.

    0 讨论(0)
提交回复
热议问题