class Jenkins2API::Endpoint::Job

This class contains all the calls to reach Jenkins2 and obtain Build data

Public Instance Methods

build(name, parameters = {}, delay = 0) click to toggle source

Trigger a build on a specific job

Params:

name

Name of the job

parameters

Hash with build parameters,

key => valule pairs
delay

Delay the build in seconds

# File lib/endpoints/job.rb, line 51
def build(name, parameters = {}, delay = 0)
  post = { parameter: [] }
  parameters.each do |key, value|
    post[:parameter] << { name: key, value: value }
  end

  @client.api_request(
    :post,
    "/job/#{name}/build?delay=#{delay}sec",
    :raw,
    json: post.to_json
  )
end
builds(name) click to toggle source

Get all available builds for a specific job

Params:

name

Name of the Job

Returns with an array of builds

# File lib/endpoints/job.rb, line 30
def builds(name)
  @client.api_request(:get, "/job/#{name}")['builds']
end
Also aliased as: get_builds
get_builds(name)

Compatibility with jenkins-api gem (for Jenkins1)

Alias for: builds
get_test_results(name, build_id) click to toggle source

Get test results “alias” Why? Because jenkins1 api gem uses this logic Why? I don't know.

Params:

name

Name of the Job

build_id

ID of the build

# File lib/endpoints/job.rb, line 20
def get_test_results(name, build_id)
  @client.build.test_results(name, build_id)
end
jobs(name) click to toggle source

Get all available sub-jobs for a specific job

Params:

name

Name of the Job

Returns with an array of jobs

# File lib/endpoints/job.rb, line 40
def jobs(name)
  @client.api_request(:get, "/job/#{name}")['jobs']
end
list() click to toggle source

Lists all available jobs

# File lib/endpoints/job.rb, line 9
def list
  @client.api_request(:get, '')['jobs']
end