Module: Veyor

Extended by:
Configuration
Defined in:
lib/veyor/request.rb,
lib/veyor.rb,
lib/veyor/version.rb

Overview

veyor::Request

Class to perform HTTP requests to the Appveyor API

Defined Under Namespace

Classes: Request

Constant Summary collapse

VERSION =
"0.3.0"

Class Method Summary collapse

Methods included from Configuration

configuration, define_setting

Class Method Details

.build_artifacts(job_id:, options: nil, verbose: false) ⇒ Array

List artifacts of a job

Examples:

require 'veyor'
x = Veyor.build_artifacts(job_id: '4b9u720e2sjulln9')

Parameters:

  • job_id (String)

    Job ID

  • options (Hash) (defaults to: nil)

    Hash of options for configuring the request, passed on to Faraday.new

    • timeout [Fixnum] open/read timeout Integer in seconds

    • open_timeout [Fixnum] read timeout Integer in seconds

    • proxy [Hash] hash of proxy options

      • uri [String] Proxy Server URI

      • user [String] Proxy server username

      • password [String] Proxy server password

    • params_encoder [Hash] not sure what this is

    • bind [Hash] A hash with host and port values

    • boundary [String] of the boundary value

    • oauth [Hash] A hash with OAuth details

  • verbose (Boolean) (defaults to: false)

    Print request headers to stdout. Default: false

Returns:

  • (Array)

    An array of hashes



312
313
314
315
# File 'lib/veyor.rb', line 312

def self.build_artifacts(job_id:, options: nil, verbose: false)
  route = sprintf('/buildjobs/%s/artifacts', job_id)
  Request.new(route, {}, nil, options, verbose).get
end

.build_cancel(account: nil, project:, version:, options: nil, verbose: false) ⇒ Int

Cancel a build

Examples:

require 'veyor'
# start a build
x = Veyor.build_start(project: 'cowsay')
x = Veyor.build_cancel(project: 'cowsay', version: '1.0.6088')

Parameters:

  • account (String) (defaults to: nil)

    An Appveyor account name

  • project (String)

    An Appveyor project name

  • version (String)

    Project version

  • options (Hash) (defaults to: nil)

    Hash of options for configuring the request, passed on to Faraday.new

    • timeout [Fixnum] open/read timeout Integer in seconds

    • open_timeout [Fixnum] read timeout Integer in seconds

    • proxy [Hash] hash of proxy options

      • uri [String] Proxy Server URI

      • user [String] Proxy server username

      • password [String] Proxy server password

    • params_encoder [Hash] not sure what this is

    • bind [Hash] A hash with host and port values

    • boundary [String] of the boundary value

    • oauth [Hash] A hash with OAuth details

  • verbose (Boolean) (defaults to: false)

    Print request headers to stdout. Default: false

Returns:

  • (Int)

    204 on success



262
263
264
265
# File 'lib/veyor.rb', line 262

def self.build_cancel(account: nil, project:, version:, options: nil, verbose: false)
  route = sprintf('/builds/%s/%s/%s', (), project, version)
  Request.new(route, {}, nil, options, verbose).delete
end

.build_delete(build_id:, options: nil, verbose: false) ⇒ Int

Delete a build

Examples:

require 'veyor'
# start a build
x = Veyor.build_start(project: 'cowsay')
x = Veyor.build_delete(build_id: '17962865')

Parameters:

  • build_id (String)

    Build ID

  • options (Hash) (defaults to: nil)

    Hash of options for configuring the request, passed on to Faraday.new

    • timeout [Fixnum] open/read timeout Integer in seconds

    • open_timeout [Fixnum] read timeout Integer in seconds

    • proxy [Hash] hash of proxy options

      • uri [String] Proxy Server URI

      • user [String] Proxy server username

      • password [String] Proxy server password

    • params_encoder [Hash] not sure what this is

    • bind [Hash] A hash with host and port values

    • boundary [String] of the boundary value

    • oauth [Hash] A hash with OAuth details

  • verbose (Boolean) (defaults to: false)

    Print request headers to stdout. Default: false

Returns:

  • (Int)

    204 on success



280
281
282
283
# File 'lib/veyor.rb', line 280

def self.build_delete(build_id:, options: nil, verbose: false)
  route = sprintf('/builds/%s', build_id)
  Request.new(route, {}, nil, options, verbose).delete
end

.build_log(job_id:, options: nil, verbose: false) ⇒ Array

Download a build log

Examples:

require 'veyor'
x = Veyor.build_log(job_id: '4b9u720e2sjulln9')

Parameters:

  • job_id (String)

    Job ID

  • options (Hash) (defaults to: nil)

    Hash of options for configuring the request, passed on to Faraday.new

    • timeout [Fixnum] open/read timeout Integer in seconds

    • open_timeout [Fixnum] read timeout Integer in seconds

    • proxy [Hash] hash of proxy options

      • uri [String] Proxy Server URI

      • user [String] Proxy server username

      • password [String] Proxy server password

    • params_encoder [Hash] not sure what this is

    • bind [Hash] A hash with host and port values

    • boundary [String] of the boundary value

    • oauth [Hash] A hash with OAuth details

  • verbose (Boolean) (defaults to: false)

    Print request headers to stdout. Default: false

Returns:

  • (Array)

    An array of hashes



296
297
298
299
# File 'lib/veyor.rb', line 296

def self.build_log(job_id:, options: nil, verbose: false)
  route = sprintf('/buildjobs/%s/log', job_id)
  Request.new(route, {}, nil, options, verbose).get
end

.build_start(account: nil, project:, branch: 'master', options: nil, verbose: false) ⇒ Array

Start build of branch of most recent commit

Examples:

require 'veyor'
# start a build
x = Veyor.build_start(project: 'cowsay')

Parameters:

  • account (String) (defaults to: nil)

    An Appveyor account name

  • project (String)

    An Appveyor project name

  • options (Hash) (defaults to: nil)

    Hash of options for configuring the request, passed on to Faraday.new

    • timeout [Fixnum] open/read timeout Integer in seconds

    • open_timeout [Fixnum] read timeout Integer in seconds

    • proxy [Hash] hash of proxy options

      • uri [String] Proxy Server URI

      • user [String] Proxy server username

      • password [String] Proxy server password

    • params_encoder [Hash] not sure what this is

    • bind [Hash] A hash with host and port values

    • boundary [String] of the boundary value

    • oauth [Hash] A hash with OAuth details

  • verbose (Boolean) (defaults to: false)

    Print request headers to stdout. Default: false

  • branch (String) (defaults to: 'master')

    Branch name

Returns:

  • (Array)

    An array of hashes



242
243
244
245
246
# File 'lib/veyor.rb', line 242

def self.build_start(account: nil, project:, branch: 'master', options: nil, verbose: false)
  body = { :accountName => (),
    :projectSlug => project, :branch => branch }
  Request.new('builds', {}, body, options, verbose).post
end

.environment_settings(id:, options: nil, verbose: false) ⇒ Array

Get environment settings

Examples:

require 'veyor'
Veyor.environment_settings(id: 123456)

Parameters:

  • id (String)

    A deployment environment ID

  • options (Hash) (defaults to: nil)

    Hash of options for configuring the request, passed on to Faraday.new

    • timeout [Fixnum] open/read timeout Integer in seconds

    • open_timeout [Fixnum] read timeout Integer in seconds

    • proxy [Hash] hash of proxy options

      • uri [String] Proxy Server URI

      • user [String] Proxy server username

      • password [String] Proxy server password

    • params_encoder [Hash] not sure what this is

    • bind [Hash] A hash with host and port values

    • boundary [String] of the boundary value

    • oauth [Hash] A hash with OAuth details

  • verbose (Boolean) (defaults to: false)

    Print request headers to stdout. Default: false

Returns:

  • (Array)

    An array of hashes



342
343
344
345
# File 'lib/veyor.rb', line 342

def self.environment_settings(id:, options: nil, verbose: false)
  route = sprintf('/environments/%s/settings', id)
  Request.new(route, {}, nil, options, verbose).get
end

.environments(options: nil, verbose: false) ⇒ Array

environments

Get environments

Examples:

require 'veyor'
x = Veyor.environments

Parameters:

  • options (Hash) (defaults to: nil)

    Hash of options for configuring the request, passed on to Faraday.new

    • timeout [Fixnum] open/read timeout Integer in seconds

    • open_timeout [Fixnum] read timeout Integer in seconds

    • proxy [Hash] hash of proxy options

      • uri [String] Proxy Server URI

      • user [String] Proxy server username

      • password [String] Proxy server password

    • params_encoder [Hash] not sure what this is

    • bind [Hash] A hash with host and port values

    • boundary [String] of the boundary value

    • oauth [Hash] A hash with OAuth details

  • verbose (Boolean) (defaults to: false)

    Print request headers to stdout. Default: false

Returns:

  • (Array)

    An array of hashes



328
329
330
# File 'lib/veyor.rb', line 328

def self.environments(options: nil, verbose: false)
  Request.new('environments', {}, nil, options, verbose).get
end

.project(account: nil, project: nil, branch: nil, version: nil, options: nil, verbose: false) ⇒ Array

Get a single project - gets the latest build

Examples:

require 'veyor'
# if account_name already set up
Veyor.project(project: 'cowsay')

# if not, or to fetch a project not under your account
Veyor.project(account: 'sckott', project: 'cowsay')

# get by branch
Veyor.project(project: 'cowsay', branch: 'changeback')

# get by version
Veyor.project(project: 'cowsay', version: '1.0.692')

Parameters:

  • account (String) (defaults to: nil)

    An Appveyor account name

  • project (String) (defaults to: nil)

    An Appveyor project name

  • options (Hash) (defaults to: nil)

    Hash of options for configuring the request, passed on to Faraday.new

    • timeout [Fixnum] open/read timeout Integer in seconds

    • open_timeout [Fixnum] read timeout Integer in seconds

    • proxy [Hash] hash of proxy options

      • uri [String] Proxy Server URI

      • user [String] Proxy server username

      • password [String] Proxy server password

    • params_encoder [Hash] not sure what this is

    • bind [Hash] A hash with host and port values

    • boundary [String] of the boundary value

    • oauth [Hash] A hash with OAuth details

  • verbose (Boolean) (defaults to: false)

    Print request headers to stdout. Default: false

  • branch (String) (defaults to: nil)

    Branch name

  • version (String) (defaults to: nil)

    Project version

Returns:

  • (Array)

    An array of hashes



112
113
114
115
116
117
# File 'lib/veyor.rb', line 112

def self.project(account: nil, project: nil, branch: nil,
  version: nil, options: nil, verbose: false)

  route = prep_route('projects', (), project, branch, version)
  Request.new(route, {}, nil, options, verbose).get
end

.project_add(provider:, slug:, options: nil, verbose: false) ⇒ Hash

Add a project

Examples:

require 'veyor'
Veyor.project_add(provider: 'gitHub', slug: 'sckott/httpcode')

Parameters:

  • provider (String)

    provider name, one of gitHub, bitBucket, vso, gitLab, kiln, stash, git, mercurial, subversion

  • slug (String)

    a project slug like e.g., foo/bar

  • options (Hash) (defaults to: nil)

    Hash of options for configuring the request, passed on to Faraday.new

    • timeout [Fixnum] open/read timeout Integer in seconds

    • open_timeout [Fixnum] read timeout Integer in seconds

    • proxy [Hash] hash of proxy options

      • uri [String] Proxy Server URI

      • user [String] Proxy server username

      • password [String] Proxy server password

    • params_encoder [Hash] not sure what this is

    • bind [Hash] A hash with host and port values

    • boundary [String] of the boundary value

    • oauth [Hash] A hash with OAuth details

  • verbose (Boolean) (defaults to: false)

    Print request headers to stdout. Default: false

Returns:

  • (Hash)

    A hash



132
133
134
135
136
137
# File 'lib/veyor.rb', line 132

def self.project_add(provider:, slug:, options: nil, verbose: false)
  route = prep_route('projects', nil, nil, nil, nil)
  body = { :repositoryProvider => check_provider(provider),
    :repositoryName => slug }
  Request.new(route, {}, body, options, verbose).post
end

.project_delete(account:, project:, options: nil, verbose: false) ⇒ Int

Delete a project

Examples:

require 'veyor'
Veyor.project_delete(account: 'sckott', project: 'httpcode')

Parameters:

  • account (String)

    An Appveyor account name

  • project (String)

    An Appveyor project name

  • options (Hash) (defaults to: nil)

    Hash of options for configuring the request, passed on to Faraday.new

    • timeout [Fixnum] open/read timeout Integer in seconds

    • open_timeout [Fixnum] read timeout Integer in seconds

    • proxy [Hash] hash of proxy options

      • uri [String] Proxy Server URI

      • user [String] Proxy server username

      • password [String] Proxy server password

    • params_encoder [Hash] not sure what this is

    • bind [Hash] A hash with host and port values

    • boundary [String] of the boundary value

    • oauth [Hash] A hash with OAuth details

  • verbose (Boolean) (defaults to: false)

    Print request headers to stdout. Default: false

Returns:

  • (Int)

    204 on success



150
151
152
153
# File 'lib/veyor.rb', line 150

def self.project_delete(account:, project:, options: nil, verbose: false)
  route = prep_route('projects', , project, nil, nil)
  Request.new(route, {}, nil, options, verbose).delete
end

.project_deployments(account: nil, project: nil, options: nil, verbose: false) ⇒ Array

Get project deployments

Examples:

require 'veyor'
# get project deployments
x = Veyor.project_deployments(project: 'cowsay');
x['deployments']

Parameters:

  • account (String) (defaults to: nil)

    An Appveyor account name

  • project (String) (defaults to: nil)

    An Appveyor project name

  • options (Hash) (defaults to: nil)

    Hash of options for configuring the request, passed on to Faraday.new

    • timeout [Fixnum] open/read timeout Integer in seconds

    • open_timeout [Fixnum] read timeout Integer in seconds

    • proxy [Hash] hash of proxy options

      • uri [String] Proxy Server URI

      • user [String] Proxy server username

      • password [String] Proxy server password

    • params_encoder [Hash] not sure what this is

    • bind [Hash] A hash with host and port values

    • boundary [String] of the boundary value

    • oauth [Hash] A hash with OAuth details

  • verbose (Boolean) (defaults to: false)

    Print request headers to stdout. Default: false

Returns:

  • (Array)

    An array of hashes



199
200
201
202
# File 'lib/veyor.rb', line 199

def self.project_deployments(account: nil, project: nil, options: nil, verbose: false)
  route = sprintf('/projects/%s/%s/deployments', (), project)
  Request.new(route, {}, nil, options, verbose).get
end

.project_history(account: nil, project: nil, limit: 10, start_build: nil, branch: nil, options: nil, verbose: false) ⇒ Array

Get project history

Examples:

require 'veyor'
# get project history
x = Veyor.project_history(project: 'cowsay');
x['builds'].collect { |x| x['status'] }

# limit results
Veyor.project_history(project: 'cowsay', limit: 3)

# start by a certain build version
Veyor.project_history(project: 'cowsay', start_build: 2872582)

# get by branch
Veyor.project_history(project: 'cowsay', branch: 'changeback')

Parameters:

  • account (String) (defaults to: nil)

    An Appveyor account name

  • project (String) (defaults to: nil)

    An Appveyor project name

  • options (Hash) (defaults to: nil)

    Hash of options for configuring the request, passed on to Faraday.new

    • timeout [Fixnum] open/read timeout Integer in seconds

    • open_timeout [Fixnum] read timeout Integer in seconds

    • proxy [Hash] hash of proxy options

      • uri [String] Proxy Server URI

      • user [String] Proxy server username

      • password [String] Proxy server password

    • params_encoder [Hash] not sure what this is

    • bind [Hash] A hash with host and port values

    • boundary [String] of the boundary value

    • oauth [Hash] A hash with OAuth details

  • limit (Fixnum) (defaults to: 10)

    Records per page

  • start_build (String) (defaults to: nil)

    Build version to start at

  • branch (String) (defaults to: nil)

    Branch name

  • verbose (Boolean) (defaults to: false)

    Print request headers to stdout. Default: false

Returns:

  • (Array)

    An array of hashes



178
179
180
181
182
183
184
# File 'lib/veyor.rb', line 178

def self.project_history(account: nil, project: nil, limit: 10,
  start_build: nil, branch: nil, options: nil, verbose: false)

  route = sprintf('/projects/%s/%s/history', (), project)
  args = prep_args(limit, start_build, branch)
  Request.new(route, args, nil, options, verbose).get
end

.project_settings(account: nil, project: nil, yaml: false, options: nil, verbose: false) ⇒ Array

Get project settings

Examples:

require 'veyor'
# get project history
x = Veyor.project_settings(project: 'cowsay')
x['settings']
x['settings']['configuration']
# get yaml data
x = Veyor.project_settings(project: 'cowsay', yaml: true)

Parameters:

  • account (String) (defaults to: nil)

    An Appveyor account name

  • project (String) (defaults to: nil)

    An Appveyor project name

  • yaml (Boolean) (defaults to: false)

    Return yaml version of project settings. Default: false

  • options (Hash) (defaults to: nil)

    Hash of options for configuring the request, passed on to Faraday.new

    • timeout [Fixnum] open/read timeout Integer in seconds

    • open_timeout [Fixnum] read timeout Integer in seconds

    • proxy [Hash] hash of proxy options

      • uri [String] Proxy Server URI

      • user [String] Proxy server username

      • password [String] Proxy server password

    • params_encoder [Hash] not sure what this is

    • bind [Hash] A hash with host and port values

    • boundary [String] of the boundary value

    • oauth [Hash] A hash with OAuth details

  • verbose (Boolean) (defaults to: false)

    Print request headers to stdout. Default: false

Returns:

  • (Array)

    An array of hashes



221
222
223
224
225
226
227
# File 'lib/veyor.rb', line 221

def self.project_settings(account: nil, project: nil, yaml: false, options: nil, verbose: false)
  route = sprintf('/projects/%s/%s/settings', (), project)
  if yaml
    route = route + '/yaml'
  end
  Request.new(route, {}, nil, options, verbose).get
end

.projects(options: nil, verbose: false) ⇒ Array

Fetch projects

Examples:

require 'veyor'
Veyor.projects

Parameters:

  • options (Hash) (defaults to: nil)

    Hash of options for configuring the request, passed on to Faraday.new

    • timeout [Fixnum] open/read timeout Integer in seconds

    • open_timeout [Fixnum] read timeout Integer in seconds

    • proxy [Hash] hash of proxy options

      • uri [String] Proxy Server URI

      • user [String] Proxy server username

      • password [String] Proxy server password

    • params_encoder [Hash] not sure what this is

    • bind [Hash] A hash with host and port values

    • boundary [String] of the boundary value

    • oauth [Hash] A hash with OAuth details

  • verbose (Boolean) (defaults to: false)

    Print request headers to stdout. Default: false

Returns:

  • (Array)

    An array of hashes



84
85
86
87
# File 'lib/veyor.rb', line 84

def self.projects(options: nil, verbose: false)
  route = prep_route('projects', nil, nil, nil, nil)
  Request.new(route, {}, nil, options, verbose).get
end