Passing data between jobs

https://www.rundeck.com/blog/output-processing-data-passing-preview
https://github.com/rundeck/rundeck/issues/3038#issuecomment-355629323

First job :

Name: CheckServerConnection

Just below Global log filter

  1. Click on Add
  2. Select Key Value Data
  3. Don’t touch the pattern (for this example) and click on save

In the script we are checking the connection to different server and echoing the name of the one first available from a list.

echo RUNDECK:DATA:ServerKey=$host

You need to add RUNDECK:DATA: because that’s what the regex is about. ServerKey is our keyname that will be used after. $host is the name of the server in a variable, you can add it directly if you want.

Global variable parameter

Replace localnodename with the localname of the rundeck server (unfortunatly without it I can’t get the variable).

Select Execute Locally

Save the job

Second job

Name: ServerScript

Add an option name node

The script contain a simple echo $HOSTNAME

in the nodes fields, select Dispatch to nodes and enter this in the filter field : ${option.node}

Third job

I named it “Link Connection - ServerScript” (first job, second job)

/!\ I need to check if this part is still needed
Just below Global log filter

  1. Click on Add
  2. Select Key Value Data
  3. Don’t touch the pattern (for this example) and click on save
    /!\

Voilà !

The ServerKey is passed to the third job who replace it in the node filter and the job is executed on this node.