fastlane-plugin-circle_ci 0.2.0 → 0.3.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 +4 -4
- data/README.md +272 -3
- data/lib/fastlane/plugin/circle_ci/actions/circleci_add_context_env_var.rb +117 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_add_project_collaborator.rb +109 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_approve_job.rb +95 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_cancel_job.rb +96 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_cancel_workflow.rb +85 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_continue_pipeline.rb +104 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_create_checkout_key.rb +110 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_create_pipeline_definition.rb +126 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_create_pipeline_definition_trigger.rb +133 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_create_pipeline_schedule.rb +160 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_create_project.rb +105 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_create_webhook.rb +155 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_delete_checkout_key.rb +93 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_delete_context_env_var.rb +110 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_delete_env_var.rb +86 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_delete_pipeline_definition.rb +91 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_delete_pipeline_schedule.rb +95 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_delete_trigger.rb +92 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_delete_webhook.rb +86 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_download_artifact.rb +119 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_download_workflow_artifacts.rb +400 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_checkout_key.rb +101 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_checkout_keys.rb +96 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_context_env_vars.rb +114 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_env_vars.rb +95 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_flaky_tests.rb +99 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_job_artifacts.rb +111 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_job_details.rb +110 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_job_tests.rb +111 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_job_timeseries.rb +131 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_my_pipelines.rb +100 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_org_summary.rb +113 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_pipeline.rb +104 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_pipeline_by_number.rb +105 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_pipeline_config.rb +92 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_pipeline_definition.rb +99 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_pipeline_definitions.rb +94 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_pipeline_values.rb +91 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_pipeline_workflows.rb +108 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_project_branches.rb +105 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_project_config.rb +104 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_project_workflow_metrics.rb +121 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_trigger.rb +99 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_user_info.rb +83 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_workflow.rb +121 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_workflow_insights.rb +157 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_workflow_job_metrics.rb +123 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_workflow_jobs.rb +109 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_workflow_runs.rb +129 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_workflow_summary.rb +118 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_get_workflow_test_metrics.rb +115 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_list_all_pipelines.rb +94 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_list_contexts.rb +132 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_list_pipeline_definition_triggers.rb +101 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_list_pipeline_schedules.rb +99 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_list_projects.rb +89 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_list_webhooks.rb +111 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_rerun_workflow.rb +101 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_set_env_var.rb +102 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_trigger_pipeline.rb +130 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_update_pipeline_definition.rb +127 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_update_pipeline_schedule.rb +134 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_update_trigger.rb +114 -0
- data/lib/fastlane/plugin/circle_ci/actions/circleci_wait_for_pipeline.rb +152 -0
- data/lib/fastlane/plugin/circle_ci/helper/circle_ci_helper.rb +102 -1
- data/lib/fastlane/plugin/circle_ci/version.rb +1 -1
- metadata +99 -7
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/circle_ci_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
CIRCLECI_WORKFLOW_JOB_METRICS = :CIRCLECI_WORKFLOW_JOB_METRICS
|
8
|
+
end
|
9
|
+
|
10
|
+
class CircleciGetWorkflowJobMetricsAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
UI.message("Getting job metrics for CircleCI workflow via Insights API v2...")
|
13
|
+
|
14
|
+
api_token = params[:api_token]
|
15
|
+
project_slug = params[:project_slug]
|
16
|
+
workflow_name = params[:workflow_name]
|
17
|
+
|
18
|
+
# Build query parameters
|
19
|
+
query_params = {}
|
20
|
+
query_params["branch"] = params[:branch] if params[:branch]
|
21
|
+
query_params["reporting-window"] = params[:reporting_window] if params[:reporting_window]
|
22
|
+
query_params["page-token"] = params[:page_token] if params[:page_token]
|
23
|
+
|
24
|
+
# Make API request
|
25
|
+
result = Helper::CircleCiHelper.get_v2("insights/#{project_slug}/workflows/#{workflow_name}/jobs", api_token, query_params)
|
26
|
+
|
27
|
+
# Store values in lane context
|
28
|
+
Actions.lane_context[SharedValues::CIRCLECI_WORKFLOW_JOB_METRICS] = result
|
29
|
+
|
30
|
+
UI.success("Successfully retrieved job metrics for workflow #{workflow_name}")
|
31
|
+
|
32
|
+
return result
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.description
|
36
|
+
"Gets summary metrics for a project workflow's jobs using Insights API v2"
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.details
|
40
|
+
"This action retrieves summary metrics for a project workflow's jobs using the CircleCI Insights API v2. Job runs going back at most 90 days are included in the aggregation window. Metrics are refreshed daily, and thus may not include executions from the last 24 hours."
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.available_options
|
44
|
+
[
|
45
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
46
|
+
env_name: "CIRCLE_CI_API_TOKEN",
|
47
|
+
description: "API Token for CircleCI API",
|
48
|
+
sensitive: true,
|
49
|
+
code_gen_sensitive: true,
|
50
|
+
is_string: true,
|
51
|
+
default_value: ENV["CIRCLE_CI_API_TOKEN"],
|
52
|
+
default_value_dynamic: true,
|
53
|
+
optional: false),
|
54
|
+
FastlaneCore::ConfigItem.new(key: :project_slug,
|
55
|
+
env_name: "CIRCLE_CI_PROJECT_SLUG",
|
56
|
+
description: "Project slug in the form of :vcs-type/:org-name/:project-name (e.g. github/myorg/myrepo)",
|
57
|
+
is_string: true,
|
58
|
+
default_value: ENV["CIRCLE_CI_PROJECT_SLUG"],
|
59
|
+
default_value_dynamic: true,
|
60
|
+
optional: false),
|
61
|
+
FastlaneCore::ConfigItem.new(key: :workflow_name,
|
62
|
+
description: "The name of the workflow",
|
63
|
+
is_string: true,
|
64
|
+
optional: false),
|
65
|
+
FastlaneCore::ConfigItem.new(key: :branch,
|
66
|
+
description: "The name of a branch to filter for",
|
67
|
+
is_string: true,
|
68
|
+
optional: true),
|
69
|
+
FastlaneCore::ConfigItem.new(key: :reporting_window,
|
70
|
+
description: "The time window used to calculate summary metrics (last-24-hours, last-7-days, last-90-days, etc.)",
|
71
|
+
is_string: true,
|
72
|
+
optional: true),
|
73
|
+
FastlaneCore::ConfigItem.new(key: :page_token,
|
74
|
+
description: "A token to retrieve the next page of results",
|
75
|
+
is_string: true,
|
76
|
+
optional: true)
|
77
|
+
]
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.output
|
81
|
+
[
|
82
|
+
['CIRCLECI_WORKFLOW_JOB_METRICS', 'A hash containing job metrics for the workflow']
|
83
|
+
]
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.return_value
|
87
|
+
"Returns a hash containing job metrics for the workflow."
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.authors
|
91
|
+
["crazymanish", "copilot"]
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.example_code
|
95
|
+
[
|
96
|
+
'circleci_get_workflow_job_metrics(
|
97
|
+
project_slug: "gh/MyOrg/my-project",
|
98
|
+
workflow_name: "build-and-test"
|
99
|
+
)',
|
100
|
+
'job_metrics = circleci_get_workflow_job_metrics(
|
101
|
+
project_slug: "gh/MyOrg/my-project",
|
102
|
+
workflow_name: "build-and-test",
|
103
|
+
branch: "main",
|
104
|
+
reporting_window: "last-30-days"
|
105
|
+
)
|
106
|
+
|
107
|
+
# Access the job metrics
|
108
|
+
job_metrics["items"].each do |job|
|
109
|
+
UI.message("Job: #{job["name"]}, Success Rate: #{job["success_rate"]}, Duration: #{job["duration_metrics"]["median"]}ms")
|
110
|
+
end'
|
111
|
+
]
|
112
|
+
end
|
113
|
+
|
114
|
+
def self.is_supported?(platform)
|
115
|
+
true
|
116
|
+
end
|
117
|
+
|
118
|
+
def self.category
|
119
|
+
:ci
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/circle_ci_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
CIRCLECI_WORKFLOW_JOBS = :CIRCLECI_WORKFLOW_JOBS
|
8
|
+
end
|
9
|
+
|
10
|
+
class CircleciGetWorkflowJobsAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
UI.message("Getting CircleCI workflow jobs via API v2...")
|
13
|
+
|
14
|
+
api_token = params[:api_token]
|
15
|
+
workflow_id = params[:workflow_id]
|
16
|
+
|
17
|
+
# Make API request
|
18
|
+
result = Helper::CircleCiHelper.get_v2("workflow/#{workflow_id}/job", api_token)
|
19
|
+
|
20
|
+
# Store values in lane context
|
21
|
+
Actions.lane_context[SharedValues::CIRCLECI_WORKFLOW_JOBS] = result["items"]
|
22
|
+
|
23
|
+
UI.success("Successfully retrieved #{result["items"].count} jobs for workflow #{workflow_id}")
|
24
|
+
|
25
|
+
return result["items"]
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.description
|
29
|
+
"Gets jobs for a CircleCI workflow using API v2"
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.details
|
33
|
+
"This action retrieves all jobs for a specific CircleCI workflow using the CircleCI API v2, including status, job numbers, and names."
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.available_options
|
37
|
+
[
|
38
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
39
|
+
env_name: "CIRCLE_CI_API_TOKEN",
|
40
|
+
description: "API Token for CircleCI API",
|
41
|
+
sensitive: true,
|
42
|
+
code_gen_sensitive: true,
|
43
|
+
is_string: true,
|
44
|
+
default_value: ENV["CIRCLE_CI_API_TOKEN"],
|
45
|
+
default_value_dynamic: true,
|
46
|
+
optional: false),
|
47
|
+
FastlaneCore::ConfigItem.new(key: :workflow_id,
|
48
|
+
env_name: "CIRCLE_CI_WORKFLOW_ID",
|
49
|
+
description: "The ID of the workflow to get jobs for",
|
50
|
+
is_string: true,
|
51
|
+
optional: false)
|
52
|
+
]
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.output
|
56
|
+
[
|
57
|
+
['CIRCLECI_WORKFLOW_JOBS', 'An array of job data for the workflow']
|
58
|
+
]
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.return_value
|
62
|
+
"Returns an array of job data including job numbers, names, and status information."
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.authors
|
66
|
+
["crazymanish", "copilot"]
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.example_code
|
70
|
+
[
|
71
|
+
'circleci_get_workflow_jobs(
|
72
|
+
workflow_id: "workflow-uuid"
|
73
|
+
)',
|
74
|
+
'jobs = circleci_get_workflow_jobs(
|
75
|
+
workflow_id: "workflow-uuid"
|
76
|
+
)
|
77
|
+
|
78
|
+
# Find jobs by status
|
79
|
+
failed_jobs = jobs.select { |job| job["status"] == "failed" }
|
80
|
+
|
81
|
+
if failed_jobs.any?
|
82
|
+
UI.error("There are #{failed_jobs.count} failed jobs in this workflow")
|
83
|
+
failed_jobs.each do |job|
|
84
|
+
puts " - #{job["name"]}: #{job["status"]}"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# Find a specific job
|
89
|
+
test_job = jobs.find { |job| job["name"] == "run-tests" }
|
90
|
+
if test_job
|
91
|
+
# Get detailed job information
|
92
|
+
job_details = circleci_get_job_details(
|
93
|
+
project_slug: "github/myorg/myrepo",
|
94
|
+
job_number: test_job["job_number"]
|
95
|
+
)
|
96
|
+
end'
|
97
|
+
]
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.is_supported?(platform)
|
101
|
+
true
|
102
|
+
end
|
103
|
+
|
104
|
+
def self.category
|
105
|
+
:ci
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/circle_ci_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
CIRCLECI_WORKFLOW_RUNS = :CIRCLECI_WORKFLOW_RUNS
|
8
|
+
end
|
9
|
+
|
10
|
+
class CircleciGetWorkflowRunsAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
UI.message("Getting recent workflow runs via Insights API v2...")
|
13
|
+
|
14
|
+
api_token = params[:api_token]
|
15
|
+
project_slug = params[:project_slug]
|
16
|
+
workflow_name = params[:workflow_name]
|
17
|
+
|
18
|
+
# Build query parameters
|
19
|
+
query_params = {}
|
20
|
+
query_params["branch"] = params[:branch] if params[:branch]
|
21
|
+
query_params["start-date"] = params[:start_date] if params[:start_date]
|
22
|
+
query_params["end-date"] = params[:end_date] if params[:end_date]
|
23
|
+
query_params["page-token"] = params[:page_token] if params[:page_token]
|
24
|
+
|
25
|
+
# Make API request
|
26
|
+
result = Helper::CircleCiHelper.get_v2("insights/#{project_slug}/workflows/#{workflow_name}", api_token, query_params)
|
27
|
+
|
28
|
+
# Store values in lane context
|
29
|
+
Actions.lane_context[SharedValues::CIRCLECI_WORKFLOW_RUNS] = result
|
30
|
+
|
31
|
+
UI.success("Successfully retrieved recent runs for workflow #{workflow_name}")
|
32
|
+
|
33
|
+
return result
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.description
|
37
|
+
"Gets recent runs of a workflow using Insights API v2"
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.details
|
41
|
+
"This action retrieves recent runs of a workflow using the CircleCI Insights API v2. Runs going back at most 90 days are returned."
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.available_options
|
45
|
+
[
|
46
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
47
|
+
env_name: "CIRCLE_CI_API_TOKEN",
|
48
|
+
description: "API Token for CircleCI API",
|
49
|
+
sensitive: true,
|
50
|
+
code_gen_sensitive: true,
|
51
|
+
is_string: true,
|
52
|
+
default_value: ENV["CIRCLE_CI_API_TOKEN"],
|
53
|
+
default_value_dynamic: true,
|
54
|
+
optional: false),
|
55
|
+
FastlaneCore::ConfigItem.new(key: :project_slug,
|
56
|
+
env_name: "CIRCLE_CI_PROJECT_SLUG",
|
57
|
+
description: "Project slug in the form of :vcs-type/:org-name/:project-name (e.g. github/myorg/myrepo)",
|
58
|
+
is_string: true,
|
59
|
+
default_value: ENV["CIRCLE_CI_PROJECT_SLUG"],
|
60
|
+
default_value_dynamic: true,
|
61
|
+
optional: false),
|
62
|
+
FastlaneCore::ConfigItem.new(key: :workflow_name,
|
63
|
+
description: "The name of the workflow",
|
64
|
+
is_string: true,
|
65
|
+
optional: false),
|
66
|
+
FastlaneCore::ConfigItem.new(key: :branch,
|
67
|
+
description: "The name of a branch to filter for",
|
68
|
+
is_string: true,
|
69
|
+
optional: true),
|
70
|
+
FastlaneCore::ConfigItem.new(key: :start_date,
|
71
|
+
description: "Include only executions that started at or after this date (format: YYYY-MM-DD)",
|
72
|
+
is_string: true,
|
73
|
+
optional: true),
|
74
|
+
FastlaneCore::ConfigItem.new(key: :end_date,
|
75
|
+
description: "Include only executions that started before this date (format: YYYY-MM-DD)",
|
76
|
+
is_string: true,
|
77
|
+
optional: true),
|
78
|
+
FastlaneCore::ConfigItem.new(key: :page_token,
|
79
|
+
description: "A token to retrieve the next page of results",
|
80
|
+
is_string: true,
|
81
|
+
optional: true)
|
82
|
+
]
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.output
|
86
|
+
[
|
87
|
+
['CIRCLECI_WORKFLOW_RUNS', 'A hash containing recent workflow runs']
|
88
|
+
]
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.return_value
|
92
|
+
"Returns a hash containing recent workflow runs."
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.authors
|
96
|
+
["crazymanish", "copilot"]
|
97
|
+
end
|
98
|
+
|
99
|
+
def self.example_code
|
100
|
+
[
|
101
|
+
'circleci_get_workflow_runs(
|
102
|
+
project_slug: "gh/MyOrg/my-project",
|
103
|
+
workflow_name: "build-and-test"
|
104
|
+
)',
|
105
|
+
'runs = circleci_get_workflow_runs(
|
106
|
+
project_slug: "gh/MyOrg/my-project",
|
107
|
+
workflow_name: "build-and-test",
|
108
|
+
branch: "main",
|
109
|
+
start_date: "2025-01-01",
|
110
|
+
end_date: "2025-04-29"
|
111
|
+
)
|
112
|
+
|
113
|
+
# Access the workflow runs
|
114
|
+
runs["items"].each do |run|
|
115
|
+
UI.message("Run ID: #{run["id"]}, Status: #{run["status"]}, Started: #{run["created_at"]}")
|
116
|
+
end'
|
117
|
+
]
|
118
|
+
end
|
119
|
+
|
120
|
+
def self.is_supported?(platform)
|
121
|
+
true
|
122
|
+
end
|
123
|
+
|
124
|
+
def self.category
|
125
|
+
:ci
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/circle_ci_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
CIRCLECI_WORKFLOW_SUMMARY = :CIRCLECI_WORKFLOW_SUMMARY
|
8
|
+
end
|
9
|
+
|
10
|
+
class CircleciGetWorkflowSummaryAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
UI.message("Getting workflow summary metrics via Insights API v2...")
|
13
|
+
|
14
|
+
api_token = params[:api_token]
|
15
|
+
project_slug = params[:project_slug]
|
16
|
+
workflow_name = params[:workflow_name]
|
17
|
+
|
18
|
+
# Build query parameters
|
19
|
+
query_params = {}
|
20
|
+
query_params["branch"] = params[:branch] if params[:branch]
|
21
|
+
query_params["reporting-window"] = params[:reporting_window] if params[:reporting_window]
|
22
|
+
|
23
|
+
# Make API request
|
24
|
+
result = Helper::CircleCiHelper.get_v2("insights/#{project_slug}/workflows/#{workflow_name}/summary", api_token, query_params)
|
25
|
+
|
26
|
+
# Store values in lane context
|
27
|
+
Actions.lane_context[SharedValues::CIRCLECI_WORKFLOW_SUMMARY] = result
|
28
|
+
|
29
|
+
UI.success("Successfully retrieved summary metrics for workflow #{workflow_name}")
|
30
|
+
|
31
|
+
return result
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.description
|
35
|
+
"Gets metrics and trends for a workflow using Insights API v2"
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.details
|
39
|
+
"This action retrieves metrics and trends for a particular workflow on a single branch or all branches using the CircleCI Insights API v2."
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.available_options
|
43
|
+
[
|
44
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
45
|
+
env_name: "CIRCLE_CI_API_TOKEN",
|
46
|
+
description: "API Token for CircleCI API",
|
47
|
+
sensitive: true,
|
48
|
+
code_gen_sensitive: true,
|
49
|
+
is_string: true,
|
50
|
+
default_value: ENV["CIRCLE_CI_API_TOKEN"],
|
51
|
+
default_value_dynamic: true,
|
52
|
+
optional: false),
|
53
|
+
FastlaneCore::ConfigItem.new(key: :project_slug,
|
54
|
+
env_name: "CIRCLE_CI_PROJECT_SLUG",
|
55
|
+
description: "Project slug in the form of :vcs-type/:org-name/:project-name (e.g. github/myorg/myrepo)",
|
56
|
+
is_string: true,
|
57
|
+
default_value: ENV["CIRCLE_CI_PROJECT_SLUG"],
|
58
|
+
default_value_dynamic: true,
|
59
|
+
optional: false),
|
60
|
+
FastlaneCore::ConfigItem.new(key: :workflow_name,
|
61
|
+
description: "The name of the workflow",
|
62
|
+
is_string: true,
|
63
|
+
optional: false),
|
64
|
+
FastlaneCore::ConfigItem.new(key: :branch,
|
65
|
+
description: "The name of a branch to filter for",
|
66
|
+
is_string: true,
|
67
|
+
optional: true),
|
68
|
+
FastlaneCore::ConfigItem.new(key: :reporting_window,
|
69
|
+
description: "The time window used to calculate summary metrics (last-24-hours, last-7-days, last-90-days, etc.)",
|
70
|
+
is_string: true,
|
71
|
+
optional: true)
|
72
|
+
]
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.output
|
76
|
+
[
|
77
|
+
['CIRCLECI_WORKFLOW_SUMMARY', 'A hash containing workflow summary metrics and trends']
|
78
|
+
]
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.return_value
|
82
|
+
"Returns a hash containing workflow summary metrics and trends."
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.authors
|
86
|
+
["crazymanish", "copilot"]
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.example_code
|
90
|
+
[
|
91
|
+
'circleci_get_workflow_summary(
|
92
|
+
project_slug: "gh/MyOrg/my-project",
|
93
|
+
workflow_name: "build-and-test"
|
94
|
+
)',
|
95
|
+
'summary = circleci_get_workflow_summary(
|
96
|
+
project_slug: "gh/MyOrg/my-project",
|
97
|
+
workflow_name: "build-and-test",
|
98
|
+
branch: "main",
|
99
|
+
reporting_window: "last-30-days"
|
100
|
+
)
|
101
|
+
|
102
|
+
# Access the workflow summary metrics
|
103
|
+
UI.message("Total Runs: #{summary["total_runs"]}")
|
104
|
+
UI.message("Success Rate: #{summary["success_rate"]}%")
|
105
|
+
UI.message("Median Duration: #{summary["duration_metrics"]["median"]} ms")'
|
106
|
+
]
|
107
|
+
end
|
108
|
+
|
109
|
+
def self.is_supported?(platform)
|
110
|
+
true
|
111
|
+
end
|
112
|
+
|
113
|
+
def self.category
|
114
|
+
:ci
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/circle_ci_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
CIRCLECI_WORKFLOW_TEST_METRICS = :CIRCLECI_WORKFLOW_TEST_METRICS
|
8
|
+
end
|
9
|
+
|
10
|
+
class CircleciGetWorkflowTestMetricsAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
UI.message("Getting test metrics for CircleCI workflow via Insights API v2...")
|
13
|
+
|
14
|
+
api_token = params[:api_token]
|
15
|
+
project_slug = params[:project_slug]
|
16
|
+
workflow_name = params[:workflow_name]
|
17
|
+
|
18
|
+
# Build query parameters
|
19
|
+
query_params = {}
|
20
|
+
query_params["branch"] = params[:branch] if params[:branch]
|
21
|
+
query_params["page-token"] = params[:page_token] if params[:page_token]
|
22
|
+
|
23
|
+
# Make API request
|
24
|
+
result = Helper::CircleCiHelper.get_v2("insights/#{project_slug}/workflows/#{workflow_name}/test-metrics", api_token, query_params)
|
25
|
+
|
26
|
+
# Store values in lane context
|
27
|
+
Actions.lane_context[SharedValues::CIRCLECI_WORKFLOW_TEST_METRICS] = result
|
28
|
+
|
29
|
+
UI.success("Successfully retrieved test metrics for workflow #{workflow_name}")
|
30
|
+
|
31
|
+
return result
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.description
|
35
|
+
"Gets test metrics for a project workflow using Insights API v2"
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.details
|
39
|
+
"This action retrieves test metrics for a project workflow using the CircleCI Insights API v2. Currently test metrics are calculated based on the 10 most recent workflow runs."
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.available_options
|
43
|
+
[
|
44
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
45
|
+
env_name: "CIRCLE_CI_API_TOKEN",
|
46
|
+
description: "API Token for CircleCI API",
|
47
|
+
sensitive: true,
|
48
|
+
code_gen_sensitive: true,
|
49
|
+
is_string: true,
|
50
|
+
default_value: ENV["CIRCLE_CI_API_TOKEN"],
|
51
|
+
default_value_dynamic: true,
|
52
|
+
optional: false),
|
53
|
+
FastlaneCore::ConfigItem.new(key: :project_slug,
|
54
|
+
env_name: "CIRCLE_CI_PROJECT_SLUG",
|
55
|
+
description: "Project slug in the form vcs-slug/org-name/repo-name",
|
56
|
+
is_string: true,
|
57
|
+
optional: false),
|
58
|
+
FastlaneCore::ConfigItem.new(key: :workflow_name,
|
59
|
+
description: "The name of the workflow",
|
60
|
+
is_string: true,
|
61
|
+
optional: false),
|
62
|
+
FastlaneCore::ConfigItem.new(key: :branch,
|
63
|
+
description: "The name of a branch to filter for",
|
64
|
+
is_string: true,
|
65
|
+
optional: true),
|
66
|
+
FastlaneCore::ConfigItem.new(key: :page_token,
|
67
|
+
description: "A token to retrieve the next page of results",
|
68
|
+
is_string: true,
|
69
|
+
optional: true)
|
70
|
+
]
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.output
|
74
|
+
[
|
75
|
+
['CIRCLECI_WORKFLOW_TEST_METRICS', 'A hash containing test metrics for the workflow']
|
76
|
+
]
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.return_value
|
80
|
+
"Returns a hash containing test metrics for the workflow."
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.authors
|
84
|
+
["crazymanish", "copilot"]
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.example_code
|
88
|
+
[
|
89
|
+
'circleci_get_workflow_test_metrics(
|
90
|
+
project_slug: "gh/MyOrg/my-project",
|
91
|
+
workflow_name: "build-and-test"
|
92
|
+
)',
|
93
|
+
'test_metrics = circleci_get_workflow_test_metrics(
|
94
|
+
project_slug: "gh/MyOrg/my-project",
|
95
|
+
workflow_name: "build-and-test",
|
96
|
+
branch: "main"
|
97
|
+
)
|
98
|
+
|
99
|
+
# Access the test metrics
|
100
|
+
test_metrics["items"].each do |test_suite|
|
101
|
+
UI.message("Test Suite: #{test_suite["test_counts"]["total"]} tests, #{test_suite["test_counts"]["fail"]} failures")
|
102
|
+
end'
|
103
|
+
]
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.is_supported?(platform)
|
107
|
+
true
|
108
|
+
end
|
109
|
+
|
110
|
+
def self.category
|
111
|
+
:ci
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/circle_ci_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
CIRCLECI_ALL_PIPELINES = :CIRCLECI_ALL_PIPELINES
|
8
|
+
end
|
9
|
+
|
10
|
+
class CircleciListAllPipelinesAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
UI.message("Getting all CircleCI pipelines via API v2...")
|
13
|
+
|
14
|
+
api_token = params[:api_token]
|
15
|
+
org_slug = params[:org_slug]
|
16
|
+
|
17
|
+
query_params = {}
|
18
|
+
query_params["org-slug"] = org_slug if org_slug
|
19
|
+
|
20
|
+
# Make API request
|
21
|
+
result = Helper::CircleCiHelper.get_v2("pipeline", api_token, query_params)
|
22
|
+
|
23
|
+
# Store values in lane context
|
24
|
+
Actions.lane_context[SharedValues::CIRCLECI_ALL_PIPELINES] = result
|
25
|
+
|
26
|
+
UI.success("Successfully retrieved all pipelines")
|
27
|
+
|
28
|
+
return result
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.description
|
32
|
+
"Gets a list of all pipelines across projects using CircleCI API v2"
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.details
|
36
|
+
"This action retrieves all pipelines for the most recently built projects (max 250) you follow in an organization using the CircleCI API v2."
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.available_options
|
40
|
+
[
|
41
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
42
|
+
env_name: "CIRCLE_CI_API_TOKEN",
|
43
|
+
description: "API Token for CircleCI API",
|
44
|
+
sensitive: true,
|
45
|
+
code_gen_sensitive: true,
|
46
|
+
is_string: true,
|
47
|
+
default_value: ENV["CIRCLE_CI_API_TOKEN"],
|
48
|
+
default_value_dynamic: true,
|
49
|
+
optional: false),
|
50
|
+
FastlaneCore::ConfigItem.new(key: :org_slug,
|
51
|
+
description: "The organization slug (optional, for filtering by organization)",
|
52
|
+
is_string: true,
|
53
|
+
optional: true)
|
54
|
+
]
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.output
|
58
|
+
[
|
59
|
+
['CIRCLECI_ALL_PIPELINES', 'A hash containing all pipelines information']
|
60
|
+
]
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.return_value
|
64
|
+
"Returns a hash containing information about all pipelines."
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.authors
|
68
|
+
["crazymanish", "copilot"]
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.example_code
|
72
|
+
[
|
73
|
+
'circleci_list_all_pipelines',
|
74
|
+
'pipelines = circleci_list_all_pipelines(
|
75
|
+
org_slug: "gh/MyOrg"
|
76
|
+
)
|
77
|
+
|
78
|
+
# Process the pipelines
|
79
|
+
pipelines["items"].each do |pipeline|
|
80
|
+
UI.message("Pipeline ID: #{pipeline["id"]}, Created: #{pipeline["created_at"]}")
|
81
|
+
end'
|
82
|
+
]
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.is_supported?(platform)
|
86
|
+
true
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.category
|
90
|
+
:ci
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|