0

For a parent RunDeck job, I want to fetch sub job names along with it's time related details like start date, end date,etc. and need to store this details into SQL DB table.

Which RunDeck API call can be used to fetch details of specific step of parent RunDeck job by passing stepctx and execution Id to API call ?

I am trying to use various APIs of 'Execution output' RunDeck API call as below,

GET /api/38/execution/{execId}/node/{nodeName}/step/{stepctx}

GET api/38/execution/{executionId}/step/{stepctx}

However, it is not providing any details of particular step in the response of the API call and showing entries as blank in the response.

"entries": []

MegaDrive68k
  • 3,768
  • 2
  • 9
  • 51
Sakshi
  • 9
  • 2

1 Answers1

0

I saw the same behavior. The stepctx format using Job Reference Steps is quite different.

I have two jobs, Parent and Child:

Parent Job:

- defaultTab: nodes
  description: ''
  executionEnabled: true
  id: 5ee2f46d-60b3-4767-ad2f-40d90c52e094
  loglevel: INFO
  name: ParentJob
  nodeFilterEditable: false
  plugins:
    ExecutionLifecycle: null
  scheduleEnabled: true
  sequence:
    commands:
    - exec: echo "hello"
    - jobref:
        group: ''
        name: ChildJob
        nodeStep: 'true'
        uuid: 98375810-165e-4578-89b8-431f4831ddda
    keepgoing: false
    strategy: node-first
  uuid: 5ee2f46d-60b3-4767-ad2f-40d90c52e094

And the Child Job:

- defaultTab: nodes
  description: ''
  executionEnabled: true
  id: 98375810-165e-4578-89b8-431f4831ddda
  loglevel: INFO
  name: ChildJob
  nodeFilterEditable: false
  plugins:
    ExecutionLifecycle: null
  scheduleEnabled: true
  sequence:
    commands:
    - exec: echo "world"
    keepgoing: false
    strategy: node-first
  uuid: 98375810-165e-4578-89b8-431f4831ddda

So, to see what stepctx was used in your execution you can print the full execution using:

curl -X GET \
  'http://localhost:4440/api/41/execution/38/output/step/' \
  --header 'Accept: application/json' \
  --header 'X-Rundeck-Auth-Token: VwOiVQO0ffGR9Gr4WjQuJfO7gJQkfY4Y'

The Answer:

{
  "id": "38",
  "offset": "1128",
  "completed": true,
  "execCompleted": true,
  "hasFailedNodes": false,
  "execState": "succeeded",
  "lastModified": "1680715613864",
  "execDuration": 545,
  "percentLoaded": 99.47089947089947,
  "totalSize": 1134,
  "retryBackoff": 0,
  "clusterExec": false,
  "serverNodeUUID": "c694e0e2-1bb3-45b9-9eb9-9b4e87bd1a77",
  "compacted": false,
  "entries": [
    {
      "time": "13:26:53",
      "absolute_time": "2023-04-05T17:26:53Z",
      "log": "hello",
      "level": "NORMAL",
      "stepctx": "1",
      "node": "localhost"
    },
    {
      "time": "13:26:53",
      "absolute_time": "2023-04-05T17:26:53Z",
      "log": "world",
      "level": "NORMAL",
      "stepctx": "2@node=localhost/1",
      "node": "localhost"
    }
  ]
}

As you see, the stepctx value for the Job Reference step is 2@node=localhost/1. So, to retrieve that specific step you can use the following call:

curl -X GET \
  'http://localhost:4440/api/41/execution/38/output/step/2@node=localhost/1' \
  --header 'Accept: application/json' \
  --header 'X-Rundeck-Auth-Token: VwOiVQO0ffGR9Gr4WjQuJfO7gJQkfY4Y'

Output:

{
  "id": "38",
  "offset": "1128",
  "completed": true,
  "execCompleted": true,
  "hasFailedNodes": false,
  "execState": "succeeded",
  "lastModified": "1680715613864",
  "execDuration": 545,
  "percentLoaded": 99.47089947089947,
  "totalSize": 1134,
  "retryBackoff": 0,
  "clusterExec": false,
  "serverNodeUUID": "c694e0e2-1bb3-45b9-9eb9-9b4e87bd1a77",
  "compacted": false,
  "filter": {
    "stepctx": "2@node=localhost/1"
  },
  "entries": [
    {
      "time": "13:26:53",
      "absolute_time": "2023-04-05T17:26:53Z",
      "log": "world",
      "level": "NORMAL",
      "stepctx": "2@node=localhost/1",
      "node": "localhost"
    }
  ]
}
MegaDrive68k
  • 3,768
  • 2
  • 9
  • 51