ci_toolkit 1.1.1 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/ci_toolkit/bitrise_client.rb +19 -13
- data/lib/ci_toolkit/bitrise_env.rb +2 -1
- data/lib/ci_toolkit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fcf70d74f81c44a53d1e29376572cc61ee57a7ccc4de59f6760b40e51cbf3269
|
4
|
+
data.tar.gz: '06944accff7798d71a65eb9197ec35312e25ec11eb0aeea8ab406bad5ce6f4d9'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34995c2d9bd64bebe00a24e20f710bdf32f0793bdefc80fadc064672109af0e29681e07af17adc9f5b0d60949e7439b3837f5cf998ee6f264758731c0c89b512
|
7
|
+
data.tar.gz: d9eb2251f6b581b5814b1635c44005294cf78b81dccc26b636981e6e4be2ec8c7e3bf58efcd8ce241e78254e86de29db56d3503faf6781f0b37c6d4478fac801
|
data/Gemfile.lock
CHANGED
@@ -6,7 +6,6 @@ require "faraday"
|
|
6
6
|
module CiToolkit
|
7
7
|
# client to use with the Bitrise API
|
8
8
|
class BitriseClient
|
9
|
-
HOST = "https://api.bitrise.io"
|
10
9
|
API_VERSION = "v0.1"
|
11
10
|
attr_reader :connection
|
12
11
|
|
@@ -15,13 +14,14 @@ module CiToolkit
|
|
15
14
|
@app_slug = app_slug
|
16
15
|
@connection = faraday
|
17
16
|
configure_connection
|
17
|
+
@connection&.use Faraday::Response::Logger, nil, { headers: true, bodies: true }
|
18
18
|
end
|
19
19
|
|
20
20
|
def configure_connection
|
21
21
|
return unless @connection.nil?
|
22
22
|
|
23
23
|
@connection = Faraday.new(
|
24
|
-
url:
|
24
|
+
url: "https://api.bitrise.io",
|
25
25
|
headers: { "Content-Type" => "application/json", "Authorization" => @token }
|
26
26
|
)
|
27
27
|
@connection.use Faraday::Request::UrlEncoded
|
@@ -32,7 +32,7 @@ module CiToolkit
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def create_pull_request_build(pull_request, branch, commit, workflow)
|
35
|
-
@connection&.post("/apps/#{@app_slug}/builds", {
|
35
|
+
@connection&.post("/#{API_VERSION}/apps/#{@app_slug}/builds", {
|
36
36
|
hook_info: { type: "bitrise" },
|
37
37
|
build_params: {
|
38
38
|
branch: branch,
|
@@ -46,24 +46,30 @@ module CiToolkit
|
|
46
46
|
|
47
47
|
def abort_pull_request_builds(pull_request, branch, commit)
|
48
48
|
find_pull_request_builds(pull_request, branch, commit).each do |build|
|
49
|
-
@connection&.post("/apps/#{@app_slug}/builds/#{build[:slug]}/abort", {
|
49
|
+
@connection&.post("/#{API_VERSION}/apps/#{@app_slug}/builds/#{build[:slug]}/abort", {
|
50
50
|
abort_reason: "Aborting due to other build failed for pull request #{pull_request}"
|
51
51
|
})
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
55
|
def find_pull_request_builds(pull_request, branch, commit)
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
56
|
+
response = @connection&.get("/#{API_VERSION}/apps/#{@app_slug}/builds", {
|
57
|
+
branch: branch,
|
58
|
+
pull_request_id: pull_request.to_i,
|
59
|
+
status: 0 # status: 0 == not finished
|
60
|
+
})
|
61
|
+
puts "Response:\n"
|
62
|
+
puts response.inspect
|
63
|
+
|
64
|
+
builds = response[:body][:data]
|
65
|
+
filter_builds_by_commit(builds, commit)
|
63
66
|
end
|
64
67
|
|
65
|
-
def
|
66
|
-
"
|
68
|
+
def filter_builds_by_commit(builds, commit)
|
69
|
+
puts "Builds:\n"
|
70
|
+
puts builds.inspect
|
71
|
+
builds&.select! { |build| build[:commit_hash] == commit }
|
72
|
+
builds || []
|
67
73
|
end
|
68
74
|
end
|
69
75
|
end
|
data/lib/ci_toolkit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ci_toolkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gero Keller
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|