class CircleCi::Project
Class for interacting with Projects
Public Class Methods
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]
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
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
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
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 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 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
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 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
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 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 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
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
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
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
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
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
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 the project
@return [CircleCi::Response] - Response
object
# File lib/circleci/project.rb, line 198 def unfollow CircleCi.request(conf, "#{base_path}/unfollow").post end