class Fastlane::Actions::EmergeComment
Public Class Methods
available_options()
click to toggle source
# File lib/fastlane/plugin/emerge/actions/emerge_comment_action.rb, line 46 def self.available_options [ FastlaneCore::ConfigItem.new(key: :api_token, env_name: "EMERGE_API_TOKEN", description: "An API token for Emerge", optional: false, type: String), FastlaneCore::ConfigItem.new(key: :gitlab_acces_token, env_name: "GITLAB_ACCESS_TOKEN", description: "An access token for Gitlab", optional: false, type: String), FastlaneCore::ConfigItem.new(key: :pr_number, description: "The PR number that triggered this upload", optional: false, type: String), FastlaneCore::ConfigItem.new(key: :build_id, description: "A string to identify this build", optional: false, type: String), FastlaneCore::ConfigItem.new(key: :base_build_id, description: "Id of the build to compare with this upload", optional: false, type: String), FastlaneCore::ConfigItem.new(key: :gitlab_url, description: "URL of the self hosted gitlab instance", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :gitlab_project_id, description: "Id of the gitlab project this upload was triggered from", optional: false, type: Integer) ] end
description()
click to toggle source
# File lib/fastlane/plugin/emerge/actions/emerge_comment_action.rb, line 38 def self.description "Post an Emerge PR comment, currently supports Gitlab only." end
is_supported?(platform)
click to toggle source
# File lib/fastlane/plugin/emerge/actions/emerge_comment_action.rb, line 81 def self.is_supported?(platform) platform == :ios end
run(params)
click to toggle source
# File lib/fastlane/plugin/emerge/actions/emerge_comment_action.rb, line 8 def self.run(params) url = 'https://api.emergetools.com/getComment' api_token = params[:api_token] gitlab_url = params[:gitlab_url] project_id = params[:gitlab_project_id] pr_number = params[:pr_number] gitlab_access_token = params[:gitlab_access_token] requestParams = { buildId: params[:build_id], baseBuildId: params[:base_build_id] } resp = Faraday.get(url, requestParams, {'x-api-token' => api_token}) case resp.status when 200 UI.message("Received comment from Emerge") baseURL = gitlab_url ? gitlab_url : "https://gitlab.com" url = "#{baseURL}/api/v4/projects/#{project_id}/merge_requests/#{pr_number}/notes" gitlabResponse = Faraday.post(url, {"body" => resp.body}, {'Authorization' => "Bearer #{gitlab_access_token}"}) case gitlabResponse.status when 200...299 UI.message("Successfully posted comment") else UI.error("Received error #{gitlabResponse.status} from Gitlab") end else UI.error("Received error #{resp.status} from Emerge") end end