Class: Fastlane::Helper::CircleCIHelper
- Inherits:
-
Object
- Object
- Fastlane::Helper::CircleCIHelper
- Includes:
- CIHelper
- Defined in:
- lib/fastlane/plugin/wpmreleasetoolkit/helper/ci_helper.rb
Instance Attribute Summary collapse
-
#login ⇒ Object
Returns the value of attribute login.
-
#organization ⇒ Object
Returns the value of attribute organization.
-
#repository ⇒ Object
Returns the value of attribute repository.
Instance Method Summary collapse
-
#command_uri ⇒ String
Command URI.
-
#initialize(login:, repository:, organization: 'wordpress-mobile') ⇒ CircleCIHelper
constructor
Initializes CircleCI helper.
-
#trigger_job(branch:, parameters: nil) ⇒ Net::HTTPResponse
Triggers a job on CI.
Constructor Details
#initialize(login:, repository:, organization: 'wordpress-mobile') ⇒ CircleCIHelper
Initializes CircleCI helper.
54 55 56 57 58 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ci_helper.rb', line 54 def initialize(login:, repository:, organization: 'wordpress-mobile') @login = login @organization = organization @repository = repository end |
Instance Attribute Details
#login ⇒ Object
Returns the value of attribute login.
46 47 48 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ci_helper.rb', line 46 def login @login end |
#organization ⇒ Object
Returns the value of attribute organization.
46 47 48 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ci_helper.rb', line 46 def organization @organization end |
#repository ⇒ Object
Returns the value of attribute repository.
46 47 48 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ci_helper.rb', line 46 def repository @repository end |
Instance Method Details
#command_uri ⇒ String
Command URI
64 65 66 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ci_helper.rb', line 64 def command_uri URI.parse("https://circleci.com/api/v2/project/github/#{@organization}/#{@repository}/pipeline") end |
#trigger_job(branch:, parameters: nil) ⇒ Net::HTTPResponse
Triggers a job on CI
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ci_helper.rb', line 74 def trigger_job(branch:, parameters: nil) headers = { 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'Circle-Token' => @login } Net::HTTP.start(command_uri.host, command_uri.port, use_ssl: true) do |http| request = Net::HTTP::Post.new(command_uri.request_uri, headers) body = { branch: branch, parameters: parameters } request.body = body.to_json response = http.request(request) return response end end |