Class: Fastlane::Actions::BitriseBuildArtifactsAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::BitriseBuildArtifactsAction
- Defined in:
- lib/fastlane/plugin/bitrise_automation/actions/bitrise_build_artifacts_action.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .download_artifact(artifact, dir) ⇒ Object
- .get_artifact_details(params, build_slug, artifact_slug) ⇒ Object
- .get_artifacts(params, build_slug) ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .return_value ⇒ Object
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
76 77 78 |
# File 'lib/fastlane/plugin/bitrise_automation/actions/bitrise_build_artifacts_action.rb', line 76 def self. ["Mario Cecchi", "Henrique Alves"] end |
.available_options ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/fastlane/plugin/bitrise_automation/actions/bitrise_build_artifacts_action.rb', line 84 def self. [ FastlaneCore::ConfigItem.new(key: :app_slug, env_name: "BITRISE_APP_SLUG", description: "The app slug of the project on Bitrise", optional: false, type: String), FastlaneCore::ConfigItem.new(key: :access_token, env_name: "BITRISE_ACCESS_TOKEN", description: "The personal access token used to call Bitrise API", optional: false, type: String), FastlaneCore::ConfigItem.new(key: :build_slug, env_name: "BITRISE_BUILD_SLUG", description: "The slug that identifies the build on Bitrise", optional: false, type: String), FastlaneCore::ConfigItem.new(key: :download_artifacts, env_name: "BITRISE_DOWNLOAD_ARTIFACTS", description: "Whether to download or not the produced artifacts", optional: true, default_value: false, is_string: false) ] end |
.description ⇒ Object
72 73 74 |
# File 'lib/fastlane/plugin/bitrise_automation/actions/bitrise_build_artifacts_action.rb', line 72 def self.description "Get the list or full contents of the artifacts produced by a build on Bitrise" end |
.download_artifact(artifact, dir) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/fastlane/plugin/bitrise_automation/actions/bitrise_build_artifacts_action.rb', line 65 def self.download_artifact(artifact, dir) file_name = artifact['title'] url = artifact['expiring_download_url'] sh("curl --fail --silent -o '#{dir}/#{file_name}' '#{url}'") end |
.get_artifact_details(params, build_slug, artifact_slug) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/fastlane/plugin/bitrise_automation/actions/bitrise_build_artifacts_action.rb', line 53 def self.get_artifact_details(params, build_slug, artifact_slug) response = Helper::BitriseRequestHelper.get(params, "builds/#{build_slug}/artifacts/#{artifact_slug}") if response.code == "200" json_response = JSON.parse(response.body)['data'] else UI.crash!("Error fetching build artifacts details on Bitrise.io. Status code: #{response.code}. #{response}") end json_response end |
.get_artifacts(params, build_slug) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/fastlane/plugin/bitrise_automation/actions/bitrise_build_artifacts_action.rb', line 11 def self.get_artifacts(params, build_slug) response = Helper::BitriseRequestHelper.get(params, "builds/#{build_slug}/artifacts") if response.code == "200" json_response = JSON.parse(response.body)['data'] else UI.crash!("Error fetching build artifacts list on Bitrise.io. Status code: #{response.code}. #{response}") end UI.("Found #{json_response.size} artifacts on Bitrise for build #{build_slug}.") artifacts = json_response.map do |artifact| { "title" => artifact["title"], "artifact_type" => artifact["artifact_type"], "slug" => artifact["slug"], "file_size_bytes" => artifact["file_size_bytes"] } end artifacts.each do |artifact| FastlaneCore::PrintTable.print_values(config: artifact, title: artifact['title']) end if params[:download_artifacts] && !artifacts.empty? artifacts_dir = 'artifacts' UI.("Download option is on. Will start download of #{artifacts.size} artifacts to '#{artifacts_dir}'.") Dir.mkdir(artifacts_dir) unless Dir.exist?(artifacts_dir) artifacts.each do |artifact| UI.("Fetching artifact '#{artifact['title']}' of type '#{artifact['artifact_type']}' (#{artifact['file_size_bytes']} bytes)...") artifact_details = get_artifact_details(params, build_slug, artifact['slug']) download_artifact(artifact_details, artifacts_dir) UI.("Finished downloading artifact '#{artifact['title']}'.") end end artifacts end |
.is_supported?(platform) ⇒ Boolean
110 111 112 |
# File 'lib/fastlane/plugin/bitrise_automation/actions/bitrise_build_artifacts_action.rb', line 110 def self.is_supported?(platform) true end |
.return_value ⇒ Object
80 81 82 |
# File 'lib/fastlane/plugin/bitrise_automation/actions/bitrise_build_artifacts_action.rb', line 80 def self.return_value "Returns the list of artifacts produced by a build on Bitrise" end |
.run(params) ⇒ Object
7 8 9 |
# File 'lib/fastlane/plugin/bitrise_automation/actions/bitrise_build_artifacts_action.rb', line 7 def self.run(params) get_artifacts(params, params[:build_slug]) end |