7

I cannot seem to find the job name of an item in the queue through the API. Am I missing something (obvious)?

I created two dummy jobs that require a machine named "build1" that is offline.

When I access http://JENKINS_URL:8080/queue/api/json I get this:

{
  "_class": "hudson.model.Queue",
  "discoverableItems": [],
  "items": [
    {
      "_class": "hudson.model.Queue$BuildableItem",
      "actions": [
        {}
      ],
      "blocked": false,
      "buildable": true,
      "id": 262,
      "inQueueSince": 1529331225093,
      "params": "",
      "stuck": true,
      "task": {
        "_class": "org.jenkinsci.plugins.workflow.support.steps.ExecutorStepExecution$PlaceholderTask"
      },
      "url": "queue/item/262/",
      "why": "build1 is offline",
      "buildableStartMilliseconds": 1529331225094,
      "pending": false
    },
    {
      "_class": "hudson.model.Queue$BuildableItem",
      "actions": [
        {}
      ],
      "blocked": false,
      "buildable": true,
      "id": 260,
      "inQueueSince": 1529331219128,
      "params": "",
      "stuck": true,
      "task": {
        "_class": "org.jenkinsci.plugins.workflow.support.steps.ExecutorStepExecution$PlaceholderTask"
      },
      "url": "queue/item/260/",
      "why": "build1 is offline",
      "buildableStartMilliseconds": 1529331219128,
      "pending": false
    }
  ]
}

And if I access http://JENKINS_URL:8080/queue/item/262/api/json I get nothing more (just the item itself).

However, if I create an item that is put on hold because crontab-created and there's the previous one still in execution, it's no longer a hudson.model.Queue$BuildableItem but a hudson.model.Queue$BlockedItem and there, the task key has a full object with more details... and the name.

Any idea as to where I can find the job name of any item in the queue (and not a specific queue, btw)?

Thanks!

Samuel GIFFARD
  • 796
  • 6
  • 22

0 Answers0