List Rundeck Jobs for a Project
1 min read

List Rundeck Jobs for a Project

List Rundeck Jobs for a Project

Now that we Rundeck have a list of project names, we might want to see which jobs were created for each project. To do this, we need:

  1. The Rundeck instance's address (server, port)
  2. The API key (api_key)
  3. A project's name (project_name)

First, we need to get the list of jobs for a project:

import requests

def listJobsForProject(server, port, api_key, project_mame):
    url =  server +':'+port+'/api/1/jobs'
    payload = { 'project':  project_mame }
    headers = {'Content-Type': 'application/json',
        'X-RunDeck-Auth-Token': api_key }
    r = requests.get(url, params=payload, headers=headers, verify=False)
    return r.text.encode('utf-8')

The result is also an XML, just like the one for the projects. Therefore, we need to parse it:

import xml.etree.ElementTree as ET

def getJobIDs(jobsinfo_xml):
    job_ids = []'Get Job IDs')
    root = ET.fromstring(jobsinfo_xml)
    for jobs in root:
        for job in jobs:
    return job_ids

At the end of this exercise, we'll have a list of job names (IDs).