ruboty-circle_ci_v2 0.1.0 → 0.2.0
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b854db3327ddfbe3bd7c0b22811646342596f9da8de867b8e9bdce61720a48d3
|
4
|
+
data.tar.gz: c37e39fea9e9bde5068a0e963615b62a667cd14e426a177a83fa527b7a3fb76c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79ebea2ee3f89dbace5e7b9ea3be3c7ca86af64ead425c10615d8d3e2148d3ab9b89ddceacf92f81be70ba4757b559a50f9e5bd7cc59d26b467df56941cfce86
|
7
|
+
data.tar.gz: 1c7e708b93f1d03549c101cf433351f3b4ded29e6cd22f74ca92188757c005c60a795b40aa11c5b1b96ad5789441d3d2c8225584b2aa91bfed2890a5e2b8baca
|
@@ -16,16 +16,12 @@ module Ruboty
|
|
16
16
|
message.robot.brain.data[NAMESPACE] ||= {}
|
17
17
|
end
|
18
18
|
|
19
|
-
def body
|
20
|
-
message[:description] || ""
|
21
|
-
end
|
22
|
-
|
23
19
|
def sender_name
|
24
20
|
message.from_name
|
25
21
|
end
|
26
22
|
|
27
23
|
def require_personal_api_token
|
28
|
-
message.reply("I don't know your CircleCI
|
24
|
+
message.reply("I don't know your CircleCI personal api token")
|
29
25
|
end
|
30
26
|
|
31
27
|
def has_personal_api_token?
|
@@ -37,7 +33,7 @@ module Ruboty
|
|
37
33
|
end
|
38
34
|
|
39
35
|
def connection
|
40
|
-
Faraday.new(url:
|
36
|
+
Faraday.new(url: circle_ci_v2_base_url) do |builder|
|
41
37
|
builder.request :url_encoded
|
42
38
|
builder.adapter :net_http
|
43
39
|
builder.basic_auth personal_api_token, ""
|
@@ -45,16 +41,8 @@ module Ruboty
|
|
45
41
|
end
|
46
42
|
end
|
47
43
|
|
48
|
-
def repository
|
49
|
-
message[:repo]
|
50
|
-
end
|
51
|
-
|
52
|
-
def api_endpoint
|
53
|
-
"#{circle_ci_v2_base_url}/#{repository}/pipeline"
|
54
|
-
end
|
55
|
-
|
56
44
|
def circle_ci_v2_base_url
|
57
|
-
"https://circleci.com/api/v2
|
45
|
+
"https://circleci.com/api/v2"
|
58
46
|
end
|
59
47
|
end
|
60
48
|
end
|
@@ -13,21 +13,35 @@ module Ruboty
|
|
13
13
|
private
|
14
14
|
|
15
15
|
def run_pipeline
|
16
|
-
connection.post do |request|
|
16
|
+
pipeline_response = connection.post("project/#{project_slug}/pipeline") do |request|
|
17
17
|
request.body = {
|
18
18
|
branch: branch,
|
19
19
|
parameters: parameters
|
20
20
|
}.to_json
|
21
21
|
end
|
22
|
-
|
22
|
+
pipeline = JSON.parse(pipeline_response.body)
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
workflow_response = connection.get("pipeline/#{pipeline["id"]}/workflow")
|
25
|
+
workflow = JSON.parse(workflow_response.body)
|
26
|
+
workflow_item_id = workflow["items"].first["id"]
|
27
|
+
workflow_item_url = "https://app.circleci.com/pipelines/#{project_slug}/#{pipeline["number"]}/workflows/#{workflow_item_id}"
|
28
|
+
|
29
|
+
message.reply("Triggered #{workflow_item_url}")
|
30
|
+
rescue => e
|
31
|
+
message.reply("An error has occurred: #{e.message}")
|
26
32
|
end
|
27
33
|
|
28
34
|
def parameters
|
29
35
|
JSON.parse(message[:params])
|
30
36
|
end
|
37
|
+
|
38
|
+
def project_slug
|
39
|
+
message[:project_slug]
|
40
|
+
end
|
41
|
+
|
42
|
+
def branch
|
43
|
+
message[:branch]
|
44
|
+
end
|
31
45
|
end
|
32
46
|
end
|
33
47
|
end
|
@@ -2,13 +2,13 @@ module Ruboty
|
|
2
2
|
module Handlers
|
3
3
|
class CircleCIV2 < Base
|
4
4
|
on(
|
5
|
-
/remember my
|
5
|
+
/remember my circleci personal api token (?<token>.+)\z/,
|
6
6
|
name: "remember",
|
7
7
|
description: "Remember sender's CircleCI personal api token",
|
8
8
|
)
|
9
9
|
|
10
10
|
on(
|
11
|
-
/run circleci pipeline of branch (?<branch>.+) on (?<
|
11
|
+
/run circleci pipeline of branch (?<branch>.+) on (?<project_slug>.+) with params (?<params>.+)\z/,
|
12
12
|
name: "run_pipeline",
|
13
13
|
description: "Run pipeline with params",
|
14
14
|
)
|
@@ -22,4 +22,4 @@ module Ruboty
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
25
|
-
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruboty-circle_ci_v2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Suzuki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruboty
|