fastlane-plugin-bitrise_automation 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b27fe1a3025eea6ee77d8505ff4183c43bb356cc71cd09c413c8849200a48971
4
- data.tar.gz: 4b3c925f4355c3f90e8400db8c9b8060e6984a0f60b48d5f00628b149bbb7c26
3
+ metadata.gz: 45bdd3a1b6931f1d714dd90b9f5b141e0a3e716b782bea685ada224ecefcf7c5
4
+ data.tar.gz: afb31287838a6eb998ff322a955536d91d6f086af4c58add8a421009fe6d98ce
5
5
  SHA512:
6
- metadata.gz: d7f1fe9010ff5c93eb8f7bef088308516e3d9cfb935e02c6f90a6d6a09545f7f3b1e78bbd78a64b7e87388067486241ee9c7e68b1889027821e47aa398f15628
7
- data.tar.gz: 22c993e63c366f99ebc0d1a8943a816d008faa2dfe6a6384d884b498e7c3e1a53d04cc3171b47741e2d3df15607d33bc5b7636f788a4185f329b1c4ecdfbc55e
6
+ metadata.gz: 5548f5e317336d05d57be210e1dcc5ce763258a79117d4b45b099a55711b8500583a1910dcb1fce68558e317d9e2df9db4c847314932585cd26f34de711c09a8
7
+ data.tar.gz: b0dedb02ba555e46b6ba8a5418584a90ba7b30043e470e4f25fe78a3108cca3e6ec3110bc4d6b7b7e96ff5f8525a4b16b3a6508ced1e8103f3ad894db2c7d5dd
data/README.md CHANGED
@@ -48,6 +48,7 @@ Use this action to trigger a workflow on Bitrise and query its status.
48
48
  | `commit_hash` | The hash of the commit that will be checked out | BITRISE_BUILD_COMMIT_HASH | |
49
49
  | `build_message` | A custom message that will be used to identify the build | BITRISE_BUILD_MESSAGE | |
50
50
  | `wait_for_build` | Whether the action should wait until the build finishes or return immediately after requesting the build | BITRISE_WAIT_FOR_BUILD | false |
51
+ | `download_artifacts` | Whether to download or not the produced artifacts | BITRISE_DOWNLOAD_ARTIFACTS | false |
51
52
 
52
53
  The returned value is a hash containing the information about the build.
53
54
 
@@ -83,7 +84,7 @@ Use this action to retrieve information about the artifacts of a build or to aut
83
84
  | `app_slug` | The app slug of the project on Bitrise | BITRISE_APP_SLUG | |
84
85
  | `access_token` | The [personal access token](https://devcenter.bitrise.io/api/authentication/) used to call Bitrise API | BITRISE_ACCESS_TOKEN | |
85
86
  | `build_slug` | The slug that identifies the build on Bitrise | BITRISE_BUILD_SLUG | |
86
- | `download` | Whether to download or not the produced artifacts | BITRISE_ARTIFACTS_DOWNLOAD | |
87
+ | `download_artifacts` | Whether to download or not the produced artifacts | BITRISE_DOWNLOAD_ARTIFACTS | false |
87
88
 
88
89
  The returned value is an list of hashes containing the information about the artifacts. If there are no artifacts, it returns an empty list.
89
90
 
@@ -5,7 +5,11 @@ module Fastlane
5
5
  module Actions
6
6
  class BitriseBuildArtifactsAction < Action
7
7
  def self.run(params)
8
- response = Helper::BitriseRequestHelper.get(params, "builds/#{params[:build_slug]}/artifacts")
8
+ get_artifacts(params, params[:build_slug])
9
+ end
10
+
11
+ def self.get_artifacts(params, build_slug)
12
+ response = Helper::BitriseRequestHelper.get(params, "builds/#{build_slug}/artifacts")
9
13
 
10
14
  if response.code == "200"
11
15
  json_response = JSON.parse(response.body)['data']
@@ -13,7 +17,7 @@ module Fastlane
13
17
  UI.crash!("Error fetching build artifacts list on Bitrise.io. Status code: #{response.code}. #{response}")
14
18
  end
15
19
 
16
- UI.message("Found #{json_response.size} artifacts on Bitrise for build #{params[:build_slug]}.")
20
+ UI.message("Found #{json_response.size} artifacts on Bitrise for build #{build_slug}.")
17
21
 
18
22
  artifacts = json_response.map do |artifact|
19
23
  {
@@ -29,14 +33,14 @@ module Fastlane
29
33
  title: artifact['title'])
30
34
  end
31
35
 
32
- if params[:download] && !artifacts.empty?
36
+ if params[:download_artifacts] && !artifacts.empty?
33
37
  artifacts_dir = 'artifacts'
34
38
  UI.message("Download option is on. Will start download of #{artifacts.size} artifacts to '#{artifacts_dir}'.")
35
39
  Dir.mkdir(artifacts_dir) unless Dir.exist?(artifacts_dir)
36
40
 
37
41
  artifacts.each do |artifact|
38
42
  UI.message("Fetching artifact '#{artifact['title']}' of type '#{artifact['artifact_type']}' (#{artifact['file_size_bytes']} bytes)...")
39
- artifact_details = get_artifact_details(params, artifact['slug'])
43
+ artifact_details = get_artifact_details(params, build_slug, artifact['slug'])
40
44
 
41
45
  download_artifact(artifact_details, artifacts_dir)
42
46
  UI.message("Finished downloading artifact '#{artifact['title']}'.")
@@ -46,8 +50,8 @@ module Fastlane
46
50
  artifacts
47
51
  end
48
52
 
49
- def self.get_artifact_details(params, artifact_slug)
50
- response = Helper::BitriseRequestHelper.get(params, "builds/#{params[:build_slug]}/artifacts/#{artifact_slug}")
53
+ def self.get_artifact_details(params, build_slug, artifact_slug)
54
+ response = Helper::BitriseRequestHelper.get(params, "builds/#{build_slug}/artifacts/#{artifact_slug}")
51
55
 
52
56
  if response.code == "200"
53
57
  json_response = JSON.parse(response.body)['data']
@@ -94,8 +98,8 @@ module Fastlane
94
98
  description: "The slug that identifies the build on Bitrise",
95
99
  optional: false,
96
100
  type: String),
97
- FastlaneCore::ConfigItem.new(key: :download,
98
- env_name: "BITRISE_ARTIFACTS_DOWNLOAD",
101
+ FastlaneCore::ConfigItem.new(key: :download_artifacts,
102
+ env_name: "BITRISE_DOWNLOAD_ARTIFACTS",
99
103
  description: "Whether to download or not the produced artifacts",
100
104
  optional: true,
101
105
  default_value: false,
@@ -35,12 +35,14 @@ module Fastlane
35
35
 
36
36
  if params[:wait_for_build]
37
37
  build_status = wait_until_build_completion(params, build_infos["build_slug"])
38
-
38
+ if params[:download_artifacts]
39
+ BitriseBuildArtifactsAction.get_artifacts(params, build_infos["build_slug"])
40
+ end
39
41
  if build_status["status"] == 1
40
42
  UI.success("Build has finished successfully on Bitrise!")
41
43
  build_infos["status"] = build_status["status_text"]
42
44
  elsif build_status["status"] == 2
43
- UI.build_failure!("Build has FAILED on Bitrise. Check more details at #{build_infos["build_url"]}.")
45
+ UI.build_failure!("Build has FAILED on Bitrise. Check more details at #{build_infos['build_url']}.")
44
46
  end
45
47
  end
46
48
 
@@ -108,6 +110,12 @@ module Fastlane
108
110
  env_name: "BITRISE_WAIT_FOR_BUILD",
109
111
  description: "Whether the action should wait until the build finishes or return immediately after requesting the build",
110
112
  optional: true,
113
+ default_value: false,
114
+ is_string: false),
115
+ FastlaneCore::ConfigItem.new(key: :download_artifacts,
116
+ env_name: "BITRISE_DOWNLOAD_ARTIFACTS",
117
+ description: "Whether to download or not the produced artifacts",
118
+ optional: true,
111
119
  default_value: false,
112
120
  is_string: false)
113
121
  ]
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module BitriseAutomation
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-bitrise_automation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Cecchi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-09 00:00:00.000000000 Z
11
+ date: 2020-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry