Search code examples
command-line-interfacerundeck

rundeck cli : get job output in my script


I'm starting a job from the cli, using rundeck-cli :

bash-4.2# java -jar rundeck-cli-2.0.5-all.jar   run --id 5a8e123456XXXXXf2b60
1514611 succeeded 2023-05-26T14:41:02Z 2023-05-26T14:41:04Z http://${RD_URL}/project/Test/execution/show/1514611 job 5a8e123456XXXXXf2b60 /MyJob

I can retrieve info about the job :

bash-4.2# java -jar rundeck-cli-2.0.5-all.jar executions  info --eid=1514611
failedNodes:
  description: sudo -u rambo -i /opt/tools/commands.sh ('MyJob')
  project: Nextgen
  successfulNodes:
    node1.example.com

  argstring:
  serverUUID: 43bc083
  dateStarted: 2023-05-26T14:41:02Z
  dateEnded: 2023-05-26T14:41:04Z
  id: 1514611
  href: http://${RD_URL}/api/37/execution/1514611
  permalink: http://${RD_URL}/project/Test/execution/show/1514611
  job:
    id: 5a8e123456XXXXXf2b60
    name: MyJob
    group:
    project: Test
    href: http://${RD_URL}/api/37/job/5a8e123456XXXXXf2b60
    permalink: http://${RD_URL}/project/Nextgen/job/show/5a8e123456XXXXXf2b60
    description:
    averageDuration: 2423

  adhoc: false
  user: admin
  status: succeeded

But I did not find yet how to retrieve the job ouptut, that I can see in the gui in http://${RD_URL}/project/Test/execution/show/1514611#output

I need this output in my script to retrieve some data.

When I try to use the follow option, after the job has finished, I only get the last line of the job output.

bash-4.2# java -jar rundeck-cli-2.0.5-all.jar executions  follow --eid=1514611
         ============================= DONE FOR Test ==========================================

How can I download the output file ?


Solution

  • you can just put the -f option to run call:

    my short cli-version:

    rd run --id=<id> -f
    

    your long jar version:

    java -jar rundeck-cli-2.0.5-all.jar   run --id 5a8e123456XXXXXf2b60 -f