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,114 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/circle_ci_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
CIRCLECI_CONTEXT_ENV_VARS = :CIRCLECI_CONTEXT_ENV_VARS
|
8
|
+
end
|
9
|
+
|
10
|
+
class CircleciGetContextEnvVarsAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
UI.message("Getting CircleCI context environment variables via API v2...")
|
13
|
+
|
14
|
+
api_token = params[:api_token]
|
15
|
+
context_id = params[:context_id]
|
16
|
+
|
17
|
+
# Make API request
|
18
|
+
result = Helper::CircleCiHelper.get_v2("context/#{context_id}/environment-variable", api_token)
|
19
|
+
|
20
|
+
# Store values in lane context
|
21
|
+
Actions.lane_context[SharedValues::CIRCLECI_CONTEXT_ENV_VARS] = result["items"]
|
22
|
+
|
23
|
+
UI.success("Successfully retrieved #{result["items"].count} environment variables for context #{context_id}")
|
24
|
+
|
25
|
+
return result["items"]
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.description
|
29
|
+
"Gets environment variables for a CircleCI context using API v2"
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.details
|
33
|
+
"This action retrieves all environment variables for a specific CircleCI context using the CircleCI API v2. For security reasons, values are not returned, only variable 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: :context_id,
|
48
|
+
env_name: "CIRCLE_CI_CONTEXT_ID",
|
49
|
+
description: "The ID of the context to get environment variables for",
|
50
|
+
is_string: true,
|
51
|
+
optional: false)
|
52
|
+
]
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.output
|
56
|
+
[
|
57
|
+
['CIRCLECI_CONTEXT_ENV_VARS', 'An array of environment variable names for the context']
|
58
|
+
]
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.return_value
|
62
|
+
"Returns an array of environment variable data. For security reasons, only variable names are provided, not values."
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.authors
|
66
|
+
["crazymanish", "copilot"]
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.example_code
|
70
|
+
[
|
71
|
+
'circleci_get_context_env_vars(
|
72
|
+
context_id: "context-uuid"
|
73
|
+
)',
|
74
|
+
'# First get all contexts, then find a specific one and its environment variables
|
75
|
+
contexts = circleci_list_contexts(
|
76
|
+
owner_slug: "github/myorg"
|
77
|
+
)
|
78
|
+
|
79
|
+
# Find the production context
|
80
|
+
prod_context = contexts.find { |c| c["name"] == "production" }
|
81
|
+
|
82
|
+
if prod_context
|
83
|
+
# Get all environment variables in the production context
|
84
|
+
env_vars = circleci_get_context_env_vars(
|
85
|
+
context_id: prod_context["id"]
|
86
|
+
)
|
87
|
+
|
88
|
+
# Check if a specific variable exists
|
89
|
+
if env_vars.any? { |var| var["variable"] == "API_KEY" }
|
90
|
+
UI.success("API_KEY is set in the production context")
|
91
|
+
else
|
92
|
+
UI.important("API_KEY is missing from the production context")
|
93
|
+
|
94
|
+
# Add the missing variable
|
95
|
+
circleci_add_context_env_var(
|
96
|
+
context_id: prod_context["id"],
|
97
|
+
env_var_name: "API_KEY",
|
98
|
+
env_var_value: "secret-api-key-value"
|
99
|
+
)
|
100
|
+
end
|
101
|
+
end'
|
102
|
+
]
|
103
|
+
end
|
104
|
+
|
105
|
+
def self.is_supported?(platform)
|
106
|
+
true
|
107
|
+
end
|
108
|
+
|
109
|
+
def self.category
|
110
|
+
:ci
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/circle_ci_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
CIRCLECI_ENV_VARS = :CIRCLECI_ENV_VARS
|
8
|
+
end
|
9
|
+
|
10
|
+
class CircleciGetEnvVarsAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
UI.message("Getting environment variables for CircleCI project via API v2...")
|
13
|
+
|
14
|
+
api_token = params[:api_token]
|
15
|
+
project_slug = params[:project_slug]
|
16
|
+
|
17
|
+
# Make API request
|
18
|
+
result = Helper::CircleCiHelper.get_v2("project/#{project_slug}/envvar", api_token)
|
19
|
+
|
20
|
+
# Store values in lane context
|
21
|
+
Actions.lane_context[SharedValues::CIRCLECI_ENV_VARS] = result["items"]
|
22
|
+
|
23
|
+
UI.success("Successfully retrieved #{result["items"].count} environment variables for project #{project_slug}")
|
24
|
+
|
25
|
+
return result["items"]
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.description
|
29
|
+
"Gets environment variables for a CircleCI project using API v2"
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.details
|
33
|
+
"This action retrieves all environment variables for a specific CircleCI project using the CircleCI API v2. Note that values are not included in the response for security reasons."
|
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: :project_slug,
|
48
|
+
env_name: "CIRCLE_CI_PROJECT_SLUG",
|
49
|
+
description: "Project slug in the form of :vcs-type/:org-name/:project-name (e.g. github/myorg/myrepo)",
|
50
|
+
is_string: true,
|
51
|
+
default_value: ENV["CIRCLE_CI_PROJECT_SLUG"],
|
52
|
+
default_value_dynamic: true,
|
53
|
+
optional: false)
|
54
|
+
]
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.output
|
58
|
+
[
|
59
|
+
['CIRCLECI_ENV_VARS', 'An array of environment variable data for the project']
|
60
|
+
]
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.return_value
|
64
|
+
"Returns an array of environment variable data including names."
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.authors
|
68
|
+
["crazymanish", "copilot"]
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.example_code
|
72
|
+
[
|
73
|
+
'circleci_get_env_vars(
|
74
|
+
project_slug: "github/myorg/myrepo"
|
75
|
+
)',
|
76
|
+
'env_vars = circleci_get_env_vars(
|
77
|
+
project_slug: "github/myorg/myrepo"
|
78
|
+
)
|
79
|
+
|
80
|
+
# Check if a specific environment variable exists
|
81
|
+
has_api_key = env_vars.any? { |var| var["name"] == "API_KEY" }
|
82
|
+
puts "API key is #{has_api_key ? "set" : "not set"} for this project"'
|
83
|
+
]
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.is_supported?(platform)
|
87
|
+
true
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.category
|
91
|
+
:ci
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/circle_ci_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
CIRCLECI_FLAKY_TESTS = :CIRCLECI_FLAKY_TESTS
|
8
|
+
end
|
9
|
+
|
10
|
+
class CircleciGetFlakyTestsAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
UI.message("Getting CircleCI flaky tests via API v2...")
|
13
|
+
|
14
|
+
api_token = params[:api_token]
|
15
|
+
project_slug = params[:project_slug]
|
16
|
+
|
17
|
+
# Make API request
|
18
|
+
result = Helper::CircleCiHelper.get_v2("insights/#{project_slug}/flaky-tests", api_token)
|
19
|
+
|
20
|
+
# Store values in lane context
|
21
|
+
Actions.lane_context[SharedValues::CIRCLECI_FLAKY_TESTS] = result
|
22
|
+
|
23
|
+
UI.success("Successfully retrieved flaky tests data for #{project_slug}")
|
24
|
+
|
25
|
+
return result
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.description
|
29
|
+
"Gets flaky tests information for a CircleCI project using API v2"
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.details
|
33
|
+
"This action retrieves information about flaky tests for a specific CircleCI project using the CircleCI API v2. This is useful for monitoring test health and improving CI reliability."
|
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: :project_slug,
|
48
|
+
env_name: "CIRCLE_CI_PROJECT_SLUG",
|
49
|
+
description: "Project slug in the form of :vcs-type/:org-name/:project-name (e.g. github/myorg/myrepo)",
|
50
|
+
is_string: true,
|
51
|
+
default_value: ENV["CIRCLE_CI_PROJECT_SLUG"],
|
52
|
+
default_value_dynamic: true,
|
53
|
+
optional: false)
|
54
|
+
]
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.output
|
58
|
+
[
|
59
|
+
['CIRCLECI_FLAKY_TESTS', 'A hash containing flaky tests information']
|
60
|
+
]
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.return_value
|
64
|
+
"Returns a hash containing flaky tests information including average test count, most failed tests, and slowest tests."
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.authors
|
68
|
+
["crazymanish", "copilot"]
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.example_code
|
72
|
+
[
|
73
|
+
'circleci_get_flaky_tests(
|
74
|
+
project_slug: "gh/MyOrg/my-project"
|
75
|
+
)',
|
76
|
+
'flaky_tests = circleci_get_flaky_tests(
|
77
|
+
project_slug: "gh/MyOrg/my-project"
|
78
|
+
)
|
79
|
+
|
80
|
+
# Take action based on flaky tests
|
81
|
+
if flaky_tests["most_failed_tests"].any?
|
82
|
+
UI.important("Found #{flaky_tests["most_failed_tests"].count} flaky tests that need attention")
|
83
|
+
flaky_tests["most_failed_tests"].each do |test|
|
84
|
+
puts " - #{test["test_name"]}: Failed #{test["times_flaked"]} times"
|
85
|
+
end
|
86
|
+
end'
|
87
|
+
]
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.is_supported?(platform)
|
91
|
+
true
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.category
|
95
|
+
:ci
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/circle_ci_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
CIRCLECI_JOB_ARTIFACTS = :CIRCLECI_JOB_ARTIFACTS
|
8
|
+
end
|
9
|
+
|
10
|
+
class CircleciGetJobArtifactsAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
UI.message("Getting artifacts for CircleCI job via API v2...")
|
13
|
+
|
14
|
+
api_token = params[:api_token]
|
15
|
+
job_number = params[:job_number]
|
16
|
+
project_slug = params[:project_slug]
|
17
|
+
|
18
|
+
# Make API request
|
19
|
+
result = Helper::CircleCiHelper.get_v2("project/#{project_slug}/job/#{job_number}/artifacts", api_token)
|
20
|
+
|
21
|
+
# Store values in lane context
|
22
|
+
Actions.lane_context[SharedValues::CIRCLECI_JOB_ARTIFACTS] = result["items"]
|
23
|
+
|
24
|
+
UI.success("Successfully retrieved #{result["items"].count} artifacts for job #{job_number}")
|
25
|
+
|
26
|
+
return result["items"]
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.description
|
30
|
+
"Gets artifacts for a CircleCI job using API v2"
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.details
|
34
|
+
"This action retrieves all artifacts generated by a specific CircleCI job using the CircleCI API v2."
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.available_options
|
38
|
+
[
|
39
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
40
|
+
env_name: "CIRCLE_CI_API_TOKEN",
|
41
|
+
description: "API Token for CircleCI API",
|
42
|
+
sensitive: true,
|
43
|
+
code_gen_sensitive: true,
|
44
|
+
is_string: true,
|
45
|
+
default_value: ENV["CIRCLE_CI_API_TOKEN"],
|
46
|
+
default_value_dynamic: true,
|
47
|
+
optional: false),
|
48
|
+
FastlaneCore::ConfigItem.new(key: :project_slug,
|
49
|
+
env_name: "CIRCLE_CI_PROJECT_SLUG",
|
50
|
+
description: "Project slug in the form of :vcs-type/:org-name/:project-name (e.g. github/myorg/myrepo)",
|
51
|
+
is_string: true,
|
52
|
+
default_value: ENV["CIRCLE_CI_PROJECT_SLUG"],
|
53
|
+
default_value_dynamic: true,
|
54
|
+
optional: false),
|
55
|
+
FastlaneCore::ConfigItem.new(key: :job_number,
|
56
|
+
env_name: "CIRCLE_CI_JOB_NUMBER",
|
57
|
+
description: "The number of the job to get artifacts for",
|
58
|
+
is_string: true,
|
59
|
+
optional: false)
|
60
|
+
]
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.output
|
64
|
+
[
|
65
|
+
['CIRCLECI_JOB_ARTIFACTS', 'An array of artifact data for the job']
|
66
|
+
]
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.return_value
|
70
|
+
"Returns an array of artifact data including URLs, paths, and node information."
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.authors
|
74
|
+
["crazymanish", "copilot"]
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.example_code
|
78
|
+
[
|
79
|
+
'circleci_get_job_artifacts(
|
80
|
+
project_slug: "github/myorg/myrepo",
|
81
|
+
job_number: "123"
|
82
|
+
)',
|
83
|
+
'artifacts = circleci_get_job_artifacts(
|
84
|
+
project_slug: "github/myorg/myrepo",
|
85
|
+
job_number: "123"
|
86
|
+
)
|
87
|
+
|
88
|
+
# Find and download a specific artifact
|
89
|
+
if artifacts.any?
|
90
|
+
test_results = artifacts.find { |a| a["path"].end_with?("test-results.xml") }
|
91
|
+
|
92
|
+
if test_results
|
93
|
+
circleci_download_artifact(
|
94
|
+
artifact_url: test_results["url"],
|
95
|
+
destination_path: "./test-results/circle-results.xml"
|
96
|
+
)
|
97
|
+
end
|
98
|
+
end'
|
99
|
+
]
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.is_supported?(platform)
|
103
|
+
true
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.category
|
107
|
+
:ci
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/circle_ci_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
CIRCLECI_JOB_DETAILS = :CIRCLECI_JOB_DETAILS
|
8
|
+
end
|
9
|
+
|
10
|
+
class CircleciGetJobDetailsAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
UI.message("Getting CircleCI job details via API v2...")
|
13
|
+
|
14
|
+
api_token = params[:api_token]
|
15
|
+
job_number = params[:job_number]
|
16
|
+
project_slug = params[:project_slug]
|
17
|
+
|
18
|
+
# Make API request
|
19
|
+
result = Helper::CircleCiHelper.get_v2("project/#{project_slug}/job/#{job_number}", api_token)
|
20
|
+
|
21
|
+
# Store values in lane context
|
22
|
+
Actions.lane_context[SharedValues::CIRCLECI_JOB_DETAILS] = result
|
23
|
+
|
24
|
+
UI.success("Successfully retrieved job details for job #{job_number}")
|
25
|
+
|
26
|
+
return result
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.description
|
30
|
+
"Gets detailed information about a CircleCI job using API v2"
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.details
|
34
|
+
"This action retrieves detailed information about a specific CircleCI job using the CircleCI API v2, including status, duration, and executor information."
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.available_options
|
38
|
+
[
|
39
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
40
|
+
env_name: "CIRCLE_CI_API_TOKEN",
|
41
|
+
description: "API Token for CircleCI API",
|
42
|
+
sensitive: true,
|
43
|
+
code_gen_sensitive: true,
|
44
|
+
is_string: true,
|
45
|
+
default_value: ENV["CIRCLE_CI_API_TOKEN"],
|
46
|
+
default_value_dynamic: true,
|
47
|
+
optional: false),
|
48
|
+
FastlaneCore::ConfigItem.new(key: :project_slug,
|
49
|
+
env_name: "CIRCLE_CI_PROJECT_SLUG",
|
50
|
+
description: "Project slug in the form of :vcs-type/:org-name/:project-name (e.g. github/myorg/myrepo)",
|
51
|
+
is_string: true,
|
52
|
+
default_value: ENV["CIRCLE_CI_PROJECT_SLUG"],
|
53
|
+
default_value_dynamic: true,
|
54
|
+
optional: false),
|
55
|
+
FastlaneCore::ConfigItem.new(key: :job_number,
|
56
|
+
env_name: "CIRCLE_CI_JOB_NUMBER",
|
57
|
+
description: "The number of the job to get details for",
|
58
|
+
is_string: true,
|
59
|
+
optional: false)
|
60
|
+
]
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.output
|
64
|
+
[
|
65
|
+
['CIRCLECI_JOB_DETAILS', 'A hash containing the job details']
|
66
|
+
]
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.return_value
|
70
|
+
"Returns a hash containing detailed job information including status, duration, and executor information."
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.authors
|
74
|
+
["crazymanish", "copilot"]
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.example_code
|
78
|
+
[
|
79
|
+
'circleci_get_job_details(
|
80
|
+
project_slug: "github/myorg/myrepo",
|
81
|
+
job_number: "123"
|
82
|
+
)',
|
83
|
+
'job_details = circleci_get_job_details(
|
84
|
+
project_slug: "github/myorg/myrepo",
|
85
|
+
job_number: "123"
|
86
|
+
)
|
87
|
+
|
88
|
+
if job_details["status"] == "success"
|
89
|
+
duration_seconds = job_details["duration"]
|
90
|
+
puts "Job completed successfully in #{duration_seconds} seconds"
|
91
|
+
|
92
|
+
# Calculate job cost
|
93
|
+
credits_per_minute = 7 # Example value, depends on your plan and resource class
|
94
|
+
minutes = (duration_seconds / 60.0).ceil
|
95
|
+
cost = minutes * credits_per_minute
|
96
|
+
puts "Estimated job cost: #{cost} credits"
|
97
|
+
end'
|
98
|
+
]
|
99
|
+
end
|
100
|
+
|
101
|
+
def self.is_supported?(platform)
|
102
|
+
true
|
103
|
+
end
|
104
|
+
|
105
|
+
def self.category
|
106
|
+
:ci
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/circle_ci_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
CIRCLECI_JOB_TESTS = :CIRCLECI_JOB_TESTS
|
8
|
+
end
|
9
|
+
|
10
|
+
class CircleciGetJobTestsAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
UI.message("Getting CircleCI job test results via API v2...")
|
13
|
+
|
14
|
+
api_token = params[:api_token]
|
15
|
+
job_number = params[:job_number]
|
16
|
+
project_slug = params[:project_slug]
|
17
|
+
|
18
|
+
# Make API request
|
19
|
+
result = Helper::CircleCiHelper.get_v2("project/#{project_slug}/#{job_number}/tests", api_token)
|
20
|
+
|
21
|
+
# Store values in lane context
|
22
|
+
Actions.lane_context[SharedValues::CIRCLECI_JOB_TESTS] = result
|
23
|
+
|
24
|
+
UI.success("Successfully retrieved test results for job #{job_number}")
|
25
|
+
|
26
|
+
return result
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.description
|
30
|
+
"Gets test metadata for a CircleCI job using API v2"
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.details
|
34
|
+
"This action retrieves test metadata for a specific CircleCI job using the CircleCI API v2. It returns detailed information about tests that were run as part of the job, including test names, classnames, results, and durations."
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.available_options
|
38
|
+
[
|
39
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
40
|
+
env_name: "CIRCLE_CI_API_TOKEN",
|
41
|
+
description: "API Token for CircleCI API",
|
42
|
+
sensitive: true,
|
43
|
+
code_gen_sensitive: true,
|
44
|
+
is_string: true,
|
45
|
+
default_value: ENV["CIRCLE_CI_API_TOKEN"],
|
46
|
+
default_value_dynamic: true,
|
47
|
+
optional: false),
|
48
|
+
FastlaneCore::ConfigItem.new(key: :project_slug,
|
49
|
+
env_name: "CIRCLE_CI_PROJECT_SLUG",
|
50
|
+
description: "Project slug in the form of vcs-type/org-name/repo-name (e.g. github/myorg/myrepo)",
|
51
|
+
is_string: true,
|
52
|
+
optional: false),
|
53
|
+
FastlaneCore::ConfigItem.new(key: :job_number,
|
54
|
+
env_name: "CIRCLE_CI_JOB_NUMBER",
|
55
|
+
description: "The number of the job to get test results for",
|
56
|
+
is_string: true,
|
57
|
+
optional: false)
|
58
|
+
]
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.output
|
62
|
+
[
|
63
|
+
['CIRCLECI_JOB_TESTS', 'A hash containing the job test results']
|
64
|
+
]
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.return_value
|
68
|
+
"Returns a hash containing detailed test results information including test names, classnames, results, and durations."
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.authors
|
72
|
+
["crazymanish", "copilot"]
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.example_code
|
76
|
+
[
|
77
|
+
'circleci_get_job_tests(
|
78
|
+
project_slug: "github/myorg/myrepo",
|
79
|
+
job_number: "123"
|
80
|
+
)',
|
81
|
+
'test_results = circleci_get_job_tests(
|
82
|
+
project_slug: "github/myorg/myrepo",
|
83
|
+
job_number: "123"
|
84
|
+
)
|
85
|
+
|
86
|
+
# Count failing tests
|
87
|
+
failing_tests = test_results["items"].select { |test| test["result"] == "failure" }
|
88
|
+
UI.message("#{failing_tests.count} failing tests found")
|
89
|
+
|
90
|
+
# Print details of failing tests
|
91
|
+
failing_tests.each do |test|
|
92
|
+
UI.error("Failed: #{test["classname"]}##{test["name"]} (#{test["file"] || "unknown file"})")
|
93
|
+
UI.error("Message: #{test["message"]}") if test["message"]
|
94
|
+
end
|
95
|
+
|
96
|
+
# Calculate total test duration
|
97
|
+
total_duration_ms = test_results["items"].sum { |test| test["run_time"] || 0 }
|
98
|
+
UI.message("Total test duration: #{total_duration_ms / 1000.0} seconds")'
|
99
|
+
]
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.is_supported?(platform)
|
103
|
+
true
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.category
|
107
|
+
:ci
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|