module Rundeck::Client::Execution

Defines methods related to executions.

Public Instance Methods

abort_execution(id, options = {}) click to toggle source

Abort a running execution

@!macro has_optional_params

@see rundeck.org/docs/api/index.html#aborting-executions

Rundeck API documentation for 'POST /api/1/execution/[ID]/abort'
endpoint

@param [String] id Execution id @!macro options @return [Rundeck::ObjectifiedHash] @!macro exceptions

# File lib/rundeck/client/execution.rb, line 119
def abort_execution(id, options = {})
  objectify post("/execution/#{id}/abort", options)['abort']
end
bulk_delete_executions(ids, options = {}) click to toggle source

Bulk delete executions

@see rundeck.org/docs/api/index.html#bulk-delete-executions

Rundeck API documentation for 'POST /api/12/executions/delete'

@param [String] ids An array of execution ids to delete @!macro options @return [Rundeck::ObjectifiedHash] @raise [Rundeck::Error::InvalidAttribites] if ids is not an array @!macro exceptions

# File lib/rundeck/client/execution.rb, line 155
def bulk_delete_executions(ids, options = {})
  unless ids.is_a?(Array)
    fail Rundeck::Error::InvalidAttributes, '`ids` must be an array of ids'
  end

  options[:query] = {} if options[:query].nil?
  options[:query].merge!(ids: ids.join(','))
  objectify post('/executions/delete', options)['deleteExecutions']
end
delete_execution(id, options = {}) click to toggle source

Delete an execution

@see rundeck.org/docs/api/index.html#delete-an-execution

Rundeck API documentation for 'DELETE /api/12/execution/[ID]' endpoint

@param [String] id Execution id @!macro options @return [nil] If the delete was successful @!macro exceptions

# File lib/rundeck/client/execution.rb, line 103
def delete_execution(id, options = {})
  delete("/execution/#{id}", options)
end
delete_job_executions(id, options = {}) click to toggle source

Delete all executions for a specific job

@see rundeck.org/docs/api/index.html#delete-all-executions-for-a-job

Rundeck API documentation for 'DELETE /api/12/job/[ID]/executions'
endpoint

@example

Rundeck.delete_job_executions('c07518ef-b697-4792-9a59-5b4f08855b67')

@param [String] id Job id @!macro options @return [Rundeck::ObjectifiedHash] @!macro exceptions

# File lib/rundeck/client/execution.rb, line 90
def delete_job_executions(id, options = {})
  objectify delete("/job/#{id}/executions", options)['deleteExecutions']
end
execute_job(id, options = {}) click to toggle source

Execute a job

@!macro has_optional_params

@see rundeck.org/docs/api/index.html#running-a-job

Rundeck API documentation for 'POST /api/12/job/[ID]/executions'
endpoint

@example

Rundeck.execute_job('c07518ef-b697-4792-9a59-5b4f08855b67')
Rundeck.run_job('c07518ef-b697-4792-9a59-5b4f08855b67')

@param [String] id Job id @!macro options @return [Rundeck::ObjectifiedHash] @!macro exceptions

# File lib/rundeck/client/execution.rb, line 21
def execute_job(id, options = {})
  e = post("/job/#{id}/executions", options)
  # Temporary fix for https://github.com/dblessing/rundeck-ruby/issues/25
  begin
    objectify e['result']['executions']
  rescue
    objectify e['executions']
  end
end
Also aliased as: run_job
execution(id, options = {}) click to toggle source

Get info for an execution

@see rundeck.org/docs/api/index.html#execution-info

Rundeck API documentation for 'GET /api/1/execution/[ID]' endpoint

@example

Rundeck.execution('c07518ef-b697-4792-9a59-5b4f08855b67'')

@param [String] id Execution id @!macro options @return [Rundeck::ObjectifiedHash] @!macro exceptions

# File lib/rundeck/client/execution.rb, line 135
def execution(id, options = {})
  e = get("/execution/#{id}", options)
  # Temporary fix for https://github.com/dblessing/rundeck-ruby/issues/25
  begin
    objectify e['result']['executions']['execution']
  rescue
    objectify e['executions']['execution']
  end
end
execution_query(project, options = {}) click to toggle source

Query for executions based on job or execution details.

@note This method maps to an advanced Rundeck endpoint. View the Rundeck

API documentation and understand what query parameters are required.
Responses may include paging details. Recall this method with the
next set of paging values to retrieve more elements.

@see rundeck.org/docs/api/index.html#execution-query

Rundeck API documentation for 'GET /api/12/executions'
# File lib/rundeck/client/execution.rb, line 187
def execution_query(project, options = {})
  options = project_options_query(project, options)
  q = get('/executions', options)
  # Temporary fix for https://github.com/dblessing/rundeck-ruby/issues/25
  begin
    objectify q['result']['executions']
  rescue
    objectify q['executions']
  end
end
execution_state(id, options = {}) click to toggle source

Get the state of an execution

@see rundeck.org/docs/api/index.html#execution-state

Rundeck API documentation for 'GET /api/12/execution/[ID]/state'

@param [String] id Execution ID @!macro options @return [Rundeck::ObjectifiedHash] @!macro exceptions

# File lib/rundeck/client/execution.rb, line 174
def execution_state(id, options = {})
  objectify get("/execution/#{id}/state", options)['result']['executionState']
end
job_executions(id, options = {}) click to toggle source

Get executions for a specific job.

@!macro has_optional_params

@see rundeck.org/docs/api/index.html#getting-executions-for-a-job

Rundeck API documentation for 'GET /api/1/job/[ID]/executions'
endpoint

@example

Rundeck.job_executions('c07518ef-b697-4792-9a59-5b4f08855b67')

@param [String] id Job id @!macro options @return [Rundeck::ObjectifiedHash] @!macro exceptions

# File lib/rundeck/client/execution.rb, line 47
def job_executions(id, options = {})
  r = get("/job/#{id}/executions", options)['result']['executions']
  objectify r
end
run_job(id, options = {})
Alias for: execute_job
running_job_executions(project, options = {}) click to toggle source

Get all running job executions

@!macro has_required_params

@see rundeck.org/docs/api/index.html#listing-running-executions

Rundeck API documentation for 'GET /api/1/executions/running' endpoint

@example

Rundeck.running_job_executions('anvils')

@param [String] project List running executions from this project @!macro options @return [Rundeck::ObjectifiedHash] @!macro exceptions

# File lib/rundeck/client/execution.rb, line 66
def running_job_executions(project, options = {})
  options = project_options_query(project, options)
  r = get('/executions/running', options)
  # Temporary fix for https://github.com/dblessing/rundeck-ruby/issues/25
  begin
    objectify r['result']['executions']
  rescue
    objectify r['executions']
  end
end

Private Instance Methods

project_options_query(project, options) click to toggle source
# File lib/rundeck/client/execution.rb, line 200
def project_options_query(project, options)
  options[:query] = {} if options[:query].nil?
  options[:query]['project'] = project
  options
end