class CircleCi::Project

Class for interacting with Projects

Public Class Methods

new(username = nil, project = nil, vcs_type = nil, conf = nil) click to toggle source

Initialize a new Project API interaction

@param username [String] - The vcs username or org name for project @param project [String] - The project name @param vcs_type [String] - The vcs type i.e. github or bitbucket @param conf [CircleCi::Config] - Optional config to use for request @return [CircleCi::Project]

Calls superclass method CircleCi::ApiProjectResource::new
# File lib/circleci/project.rb, line 17
def initialize(username = nil, project = nil, vcs_type = nil, conf = nil) # rubocop:disable Metrics/ParameterLists
  super(username, project, vcs_type, nil, conf)
end

Public Instance Methods

add_envvar(envvar) click to toggle source

Adds an envvar for a project

@param envvar [Hash] - {name: ‘foo’, value: ‘bar’} @return [CircleCi::Response] - Response object

# File lib/circleci/project.rb, line 167
def add_envvar(envvar)
  CircleCi.request(conf, "#{base_path}/envvar").post(envvar)
end
build() click to toggle source

Build the latest master push for this project

@return [CircleCi::Response] - Response object

# File lib/circleci/project.rb, line 26
def build
  CircleCi.request(conf, base_path).post
end
build_branch(branch, params = {}, body = {}) click to toggle source

Build the latest push for this branch of a specific project

@param branch [String] - Name of branch @param params [Hash] - Optional params to send for building @param body [Hash] - Optional post body with build parameters @return [CircleCi::Response] - Response object

# File lib/circleci/project.rb, line 38
def build_branch(branch, params = {}, body = {})
  CircleCi.request(conf, "#{base_path}/tree/#{branch}", params).post(body)
end
build_ssh_key(build, key, hostname) click to toggle source

Add a ssh key to a build

@param build [String] - Build number @param key [String] - The ssh private key @param hostname [String] - The hostname identified by the key @return [CircleCi::Response] - Response object

# File lib/circleci/project.rb, line 50
def build_ssh_key(build, key, hostname)
  body = { hostname: hostname, private_key: key }
  CircleCi.request(conf, "#{base_path}/#{build}/ssh-users").post(body)
end
clear_cache() click to toggle source

Clear the build cache for a specific project

@return [CircleCi::Response] - Response object

# File lib/circleci/project.rb, line 60
def clear_cache
  CircleCi.request(conf, "#{base_path}/build-cache").delete
end
delete_checkout_key(fingerprint) click to toggle source

Delete a checkout key for a project

@param fingerprint [String] - Fingerprint of a checkout key @return [CircleCi::Response] - Response object

# File lib/circleci/project.rb, line 70
def delete_checkout_key(fingerprint)
  CircleCi.request(conf, "#{base_path}/checkout-key/#{fingerprint}").delete
end
delete_envvar(envvar) click to toggle source

Deletes an envvar for a project

@param envvar [String] - ‘TESTENV’ @return [CircleCi::Response] - Response object

# File lib/circleci/project.rb, line 177
def delete_envvar(envvar)
  CircleCi.request(conf, "#{base_path}/envvar/#{envvar}").delete
end
enable() click to toggle source

Enable a project in CircleCI. Causes a CircleCI SSH key to be added to the GitHub. Requires admin privilege to the repository.

@return [CircleCi::Response] - Response object

# File lib/circleci/project.rb, line 80
def enable
  CircleCi.request(conf, "#{base_path}/enable").post
end
envvar() click to toggle source

Get the project envvars

@return [CircleCi::Response] - Response object

# File lib/circleci/project.rb, line 89
def envvar
  CircleCi.request(conf, "#{base_path}/envvar").get
end
follow() click to toggle source

Follow the project

@return [CircleCi::Response] - Response object

# File lib/circleci/project.rb, line 98
def follow
  CircleCi.request(conf, "#{base_path}/follow").post
end
get_checkout_key(fingerprint) click to toggle source

Get a checkout key for a project

@param fingerprint [String] - Fingerprint of a checkout key @return [CircleCi::Response] - Response object

# File lib/circleci/project.rb, line 108
def get_checkout_key(fingerprint)
  CircleCi.request(conf, "#{base_path}/checkout-key/#{fingerprint}").get
end
list_checkout_keys() click to toggle source

Get a list of checkout keys for project

@return [CircleCi::Response] - Response object

# File lib/circleci/project.rb, line 117
def list_checkout_keys
  CircleCi.request(conf, "#{base_path}/checkout-key").get
end
new_checkout_key(type) click to toggle source

Create a checkout key for a project

@param type [String] - The type of key to create. Can be ‘deploy-key’ or ‘github-user-key’. @return [CircleCi::Response] - Response object

# File lib/circleci/project.rb, line 127
def new_checkout_key(type)
  CircleCi.request(conf, "#{base_path}/checkout-key").post(type: type)
end
recent_builds(params = {}) click to toggle source

Get all recent builds for a specific project

@param params [Hash] - Parameters for builds (limit, offset, filter) @return [CircleCi::Response] - Response object

# File lib/circleci/project.rb, line 137
def recent_builds(params = {})
  CircleCi.request(conf, base_path, params).get
end
recent_builds_branch(branch, params = {}) click to toggle source

Get all recent builds for a specific branch of a project

@param branch [String] - Name of branch @param params [Hash] - Parameters for builds (limit, offset, filter) @return [CircleCi::Response] - Response object

# File lib/circleci/project.rb, line 148
def recent_builds_branch(branch, params = {})
  CircleCi.request(conf, "#{base_path}/tree/#{branch}", params).get
end
settings() click to toggle source

Get the project configuration

@return [CircleCi::Response] - Response object

# File lib/circleci/project.rb, line 157
def settings
  CircleCi.request(conf, "#{base_path}/settings").get
end
ssh_key(key, hostname) click to toggle source

Add a ssh key to a project

@param key [String] - The ssh private key @param hostname [String] - The hostname identified by the key @return [CircleCi::Response] - Response object

# File lib/circleci/project.rb, line 188
def ssh_key(key, hostname)
  body = { hostname: hostname, private_key: key }
  CircleCi.request(conf, "#{base_path}/ssh-key").post(body)
end
unfollow() click to toggle source

Unfollow the project

@return [CircleCi::Response] - Response object

# File lib/circleci/project.rb, line 198
def unfollow
  CircleCi.request(conf, "#{base_path}/unfollow").post
end