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,132 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/circle_ci_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
CIRCLECI_CONTEXTS = :CIRCLECI_CONTEXTS
|
8
|
+
end
|
9
|
+
|
10
|
+
class CircleciListContextsAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
UI.message("Listing CircleCI contexts via API v2...")
|
13
|
+
|
14
|
+
api_token = params[:api_token]
|
15
|
+
owner_id = params[:owner_id]
|
16
|
+
owner_type = params[:owner_type]
|
17
|
+
owner_slug = params[:owner_slug]
|
18
|
+
|
19
|
+
query_params = {}
|
20
|
+
|
21
|
+
# Determine if we're using owner-id or owner-slug
|
22
|
+
if owner_id && owner_type
|
23
|
+
query_params["owner-id"] = owner_id
|
24
|
+
query_params["owner-type"] = owner_type
|
25
|
+
UI.verbose("Using owner-id: #{owner_id} and owner-type: #{owner_type}")
|
26
|
+
elsif owner_slug
|
27
|
+
query_params["owner-slug"] = owner_slug
|
28
|
+
UI.verbose("Using owner-slug: #{owner_slug}")
|
29
|
+
else
|
30
|
+
UI.user_error!("Either owner_id and owner_type, or owner_slug must be provided")
|
31
|
+
end
|
32
|
+
|
33
|
+
# Make API request
|
34
|
+
result = Helper::CircleCiHelper.get_v2("context", api_token, query_params)
|
35
|
+
|
36
|
+
# Store values in lane context
|
37
|
+
Actions.lane_context[SharedValues::CIRCLECI_CONTEXTS] = result["items"]
|
38
|
+
|
39
|
+
UI.success("Successfully retrieved #{result["items"].count} contexts")
|
40
|
+
|
41
|
+
return result["items"]
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.description
|
45
|
+
"Lists CircleCI contexts using API v2"
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.details
|
49
|
+
"This action lists all contexts for an organization or account using the CircleCI API v2. Contexts allow you to share environment variables across multiple projects."
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.available_options
|
53
|
+
[
|
54
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
55
|
+
env_name: "CIRCLE_CI_API_TOKEN",
|
56
|
+
description: "API Token for CircleCI API",
|
57
|
+
sensitive: true,
|
58
|
+
code_gen_sensitive: true,
|
59
|
+
is_string: true,
|
60
|
+
default_value: ENV["CIRCLE_CI_API_TOKEN"],
|
61
|
+
default_value_dynamic: true,
|
62
|
+
optional: false),
|
63
|
+
FastlaneCore::ConfigItem.new(key: :owner_id,
|
64
|
+
env_name: "CIRCLE_CI_CONTEXT_OWNER_ID",
|
65
|
+
description: "The ID of the context owner (organization or account)",
|
66
|
+
is_string: true,
|
67
|
+
optional: true),
|
68
|
+
FastlaneCore::ConfigItem.new(key: :owner_type,
|
69
|
+
env_name: "CIRCLE_CI_CONTEXT_OWNER_TYPE",
|
70
|
+
description: "The type of the context owner (organization or account)",
|
71
|
+
is_string: true,
|
72
|
+
verify_block: proc do |value|
|
73
|
+
UI.user_error!("Owner type must be either 'organization' or 'account'") unless ['organization', 'account'].include?(value)
|
74
|
+
end,
|
75
|
+
optional: true),
|
76
|
+
FastlaneCore::ConfigItem.new(key: :owner_slug,
|
77
|
+
env_name: "CIRCLE_CI_CONTEXT_OWNER_SLUG",
|
78
|
+
description: "The slug of the context owner (e.g., github/myorg)",
|
79
|
+
is_string: true,
|
80
|
+
optional: true)
|
81
|
+
]
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.output
|
85
|
+
[
|
86
|
+
['CIRCLECI_CONTEXTS', 'An array of context data']
|
87
|
+
]
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.return_value
|
91
|
+
"Returns an array of context data including IDs, names, and creation timestamps."
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.authors
|
95
|
+
["crazymanish", "copilot"]
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.example_code
|
99
|
+
[
|
100
|
+
'circleci_list_contexts(
|
101
|
+
owner_slug: "github/myorg"
|
102
|
+
)',
|
103
|
+
'circleci_list_contexts(
|
104
|
+
owner_id: "organization-uuid",
|
105
|
+
owner_type: "organization"
|
106
|
+
)',
|
107
|
+
'contexts = circleci_list_contexts(
|
108
|
+
owner_slug: "github/myorg"
|
109
|
+
)
|
110
|
+
|
111
|
+
# Find a specific context
|
112
|
+
staging_context = contexts.find { |c| c["name"] == "staging" }
|
113
|
+
|
114
|
+
if staging_context
|
115
|
+
# Get environment variables for this context
|
116
|
+
env_vars = circleci_get_context_env_vars(
|
117
|
+
context_id: staging_context["id"]
|
118
|
+
)
|
119
|
+
end'
|
120
|
+
]
|
121
|
+
end
|
122
|
+
|
123
|
+
def self.is_supported?(platform)
|
124
|
+
true
|
125
|
+
end
|
126
|
+
|
127
|
+
def self.category
|
128
|
+
:ci
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/circle_ci_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
CIRCLECI_PIPELINE_DEFINITION_TRIGGERS = :CIRCLECI_PIPELINE_DEFINITION_TRIGGERS
|
8
|
+
end
|
9
|
+
|
10
|
+
class CircleciListPipelineDefinitionTriggersAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
UI.message("Getting CircleCI pipeline definition triggers via API v2...")
|
13
|
+
|
14
|
+
api_token = params[:api_token]
|
15
|
+
project_id = params[:project_id]
|
16
|
+
pipeline_definition_id = params[:pipeline_definition_id]
|
17
|
+
|
18
|
+
# Make API request
|
19
|
+
result = Helper::CircleCiHelper.get_v2("projects/#{project_id}/pipeline-definitions/#{pipeline_definition_id}/triggers", api_token)
|
20
|
+
|
21
|
+
# Store values in lane context
|
22
|
+
Actions.lane_context[SharedValues::CIRCLECI_PIPELINE_DEFINITION_TRIGGERS] = result
|
23
|
+
|
24
|
+
UI.success("Successfully retrieved pipeline definition triggers")
|
25
|
+
|
26
|
+
return result
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.description
|
30
|
+
"Gets all triggers for a pipeline definition using CircleCI API v2"
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.details
|
34
|
+
"This action retrieves all triggers configured for a specific pipeline definition using the CircleCI API v2. Pipeline definition triggers allow you to automatically start pipelines based on events."
|
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_id,
|
49
|
+
env_name: "CIRCLE_CI_PROJECT_ID",
|
50
|
+
description: "The ID of the CircleCI project",
|
51
|
+
is_string: true,
|
52
|
+
optional: false),
|
53
|
+
FastlaneCore::ConfigItem.new(key: :pipeline_definition_id,
|
54
|
+
description: "The ID of the pipeline definition",
|
55
|
+
is_string: true,
|
56
|
+
optional: false)
|
57
|
+
]
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.output
|
61
|
+
[
|
62
|
+
['CIRCLECI_PIPELINE_DEFINITION_TRIGGERS', 'A hash containing triggers information']
|
63
|
+
]
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.return_value
|
67
|
+
"Returns a hash containing pipeline definition triggers information."
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.authors
|
71
|
+
["crazymanish", "copilot"]
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.example_code
|
75
|
+
[
|
76
|
+
'circleci_list_pipeline_definition_triggers(
|
77
|
+
project_id: "01234567-89ab-cdef-0123-456789abcdef",
|
78
|
+
pipeline_definition_id: "fedcba98-7654-3210-fedc-ba9876543210"
|
79
|
+
)',
|
80
|
+
'triggers = circleci_list_pipeline_definition_triggers(
|
81
|
+
project_id: "01234567-89ab-cdef-0123-456789abcdef",
|
82
|
+
pipeline_definition_id: "fedcba98-7654-3210-fedc-ba9876543210"
|
83
|
+
)
|
84
|
+
|
85
|
+
# Use the triggers information
|
86
|
+
triggers["items"].each do |trigger|
|
87
|
+
UI.message("Trigger ID: #{trigger["id"]}, Type: #{trigger["type"]}")
|
88
|
+
end'
|
89
|
+
]
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.is_supported?(platform)
|
93
|
+
true
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.category
|
97
|
+
:ci
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
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_PIPELINE_SCHEDULES = :CIRCLECI_PIPELINE_SCHEDULES
|
8
|
+
end
|
9
|
+
|
10
|
+
class CircleciListPipelineSchedulesAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
UI.message("Listing CircleCI pipeline schedules 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}/schedule", api_token)
|
19
|
+
|
20
|
+
# Store values in lane context
|
21
|
+
Actions.lane_context[SharedValues::CIRCLECI_PIPELINE_SCHEDULES] = result["items"]
|
22
|
+
|
23
|
+
UI.success("Successfully retrieved #{result["items"].count} pipeline schedules for project #{project_slug}")
|
24
|
+
|
25
|
+
return result["items"]
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.description
|
29
|
+
"Lists pipeline schedules for a CircleCI project using API v2"
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.details
|
33
|
+
"This action retrieves all pipeline schedules for a specific CircleCI project using the CircleCI API v2."
|
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_PIPELINE_SCHEDULES', 'An array of pipeline schedule data for the project']
|
60
|
+
]
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.return_value
|
64
|
+
"Returns an array of pipeline schedule data including IDs, names, and schedule details."
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.authors
|
68
|
+
["crazymanish", "copilot"]
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.example_code
|
72
|
+
[
|
73
|
+
'circleci_list_pipeline_schedules(
|
74
|
+
project_slug: "github/myorg/myrepo"
|
75
|
+
)',
|
76
|
+
'schedules = circleci_list_pipeline_schedules(
|
77
|
+
project_slug: "github/myorg/myrepo"
|
78
|
+
)
|
79
|
+
|
80
|
+
# Find a specific schedule by name
|
81
|
+
nightly_build = schedules.find { |schedule| schedule["name"] == "Nightly Build" }
|
82
|
+
|
83
|
+
if nightly_build
|
84
|
+
puts "Nightly build schedule ID: #{nightly_build["id"]}"
|
85
|
+
puts "Schedule: #{nightly_build["description"]}"
|
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,89 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/circle_ci_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
CIRCLECI_PROJECTS = :CIRCLECI_PROJECTS
|
8
|
+
end
|
9
|
+
|
10
|
+
class CircleciListProjectsAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
UI.message("Listing CircleCI projects via API v2...")
|
13
|
+
|
14
|
+
api_token = params[:api_token]
|
15
|
+
|
16
|
+
# Make API request
|
17
|
+
result = Helper::CircleCiHelper.get_v2("projects", api_token)
|
18
|
+
|
19
|
+
# Store values in lane context
|
20
|
+
Actions.lane_context[SharedValues::CIRCLECI_PROJECTS] = result["items"]
|
21
|
+
|
22
|
+
UI.success("Successfully retrieved #{result["items"].count} projects")
|
23
|
+
|
24
|
+
return result["items"]
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.description
|
28
|
+
"Lists all CircleCI projects for the current user or organization using API v2"
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.details
|
32
|
+
"This action retrieves all CircleCI projects that the current API token has access to using the CircleCI API v2."
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.available_options
|
36
|
+
[
|
37
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
38
|
+
env_name: "CIRCLE_CI_API_TOKEN",
|
39
|
+
description: "API Token for CircleCI API",
|
40
|
+
sensitive: true,
|
41
|
+
code_gen_sensitive: true,
|
42
|
+
is_string: true,
|
43
|
+
default_value: ENV["CIRCLE_CI_API_TOKEN"],
|
44
|
+
default_value_dynamic: true,
|
45
|
+
optional: false)
|
46
|
+
]
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.output
|
50
|
+
[
|
51
|
+
['CIRCLECI_PROJECTS', 'An array of project data']
|
52
|
+
]
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.return_value
|
56
|
+
"Returns an array of project data including names, slugs, and VCS information."
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.authors
|
60
|
+
["crazymanish", "copilot"]
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.example_code
|
64
|
+
[
|
65
|
+
'circleci_list_projects',
|
66
|
+
'projects = circleci_list_projects
|
67
|
+
# Find a specific project by name
|
68
|
+
my_project = projects.find { |project| project["name"] == "my-repo-name" }
|
69
|
+
|
70
|
+
# Use the project slug for other actions
|
71
|
+
if my_project
|
72
|
+
circleci_trigger_pipeline(
|
73
|
+
project_slug: my_project["slug"],
|
74
|
+
branch: "main"
|
75
|
+
)
|
76
|
+
end'
|
77
|
+
]
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.is_supported?(platform)
|
81
|
+
true
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.category
|
85
|
+
:ci
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
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_WEBHOOKS = :CIRCLECI_WEBHOOKS
|
8
|
+
end
|
9
|
+
|
10
|
+
class CircleciListWebhooksAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
UI.message("Listing CircleCI webhooks via API v2...")
|
13
|
+
|
14
|
+
api_token = params[:api_token]
|
15
|
+
scope_id = params[:scope_id]
|
16
|
+
scope_type = params[:scope_type]
|
17
|
+
|
18
|
+
# Make API request
|
19
|
+
result = Helper::CircleCiHelper.get_v2("webhook", api_token, {
|
20
|
+
"scope-id" => scope_id,
|
21
|
+
"scope-type" => scope_type
|
22
|
+
})
|
23
|
+
|
24
|
+
# Store values in lane context
|
25
|
+
Actions.lane_context[SharedValues::CIRCLECI_WEBHOOKS] = result["items"]
|
26
|
+
|
27
|
+
UI.success("Successfully retrieved #{result["items"].count} webhooks")
|
28
|
+
|
29
|
+
return result["items"]
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.description
|
33
|
+
"Lists webhooks for a CircleCI project or organization using API v2"
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.details
|
37
|
+
"This action retrieves all webhooks defined for a specific CircleCI project or organization using the CircleCI API v2."
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.available_options
|
41
|
+
[
|
42
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
43
|
+
env_name: "CIRCLE_CI_API_TOKEN",
|
44
|
+
description: "API Token for CircleCI API",
|
45
|
+
sensitive: true,
|
46
|
+
code_gen_sensitive: true,
|
47
|
+
is_string: true,
|
48
|
+
default_value: ENV["CIRCLE_CI_API_TOKEN"],
|
49
|
+
default_value_dynamic: true,
|
50
|
+
optional: false),
|
51
|
+
FastlaneCore::ConfigItem.new(key: :scope_id,
|
52
|
+
env_name: "CIRCLE_CI_WEBHOOK_SCOPE_ID",
|
53
|
+
description: "The ID of the project or organization to list webhooks for",
|
54
|
+
is_string: true,
|
55
|
+
optional: false),
|
56
|
+
FastlaneCore::ConfigItem.new(key: :scope_type,
|
57
|
+
env_name: "CIRCLE_CI_WEBHOOK_SCOPE_TYPE",
|
58
|
+
description: "The type of scope (either 'project' or 'organization')",
|
59
|
+
is_string: true,
|
60
|
+
verify_block: proc do |value|
|
61
|
+
UI.user_error!("Scope type must be either 'project' or 'organization'") unless ['project', 'organization'].include?(value)
|
62
|
+
end,
|
63
|
+
optional: false)
|
64
|
+
]
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.output
|
68
|
+
[
|
69
|
+
['CIRCLECI_WEBHOOKS', 'An array of webhook data']
|
70
|
+
]
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.return_value
|
74
|
+
"Returns an array of webhook data including IDs, URLs, and event types."
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.authors
|
78
|
+
["crazymanish", "copilot"]
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.example_code
|
82
|
+
[
|
83
|
+
'circleci_list_webhooks(
|
84
|
+
scope_id: "project-uuid",
|
85
|
+
scope_type: "project"
|
86
|
+
)',
|
87
|
+
'circleci_list_webhooks(
|
88
|
+
scope_id: "organization-uuid",
|
89
|
+
scope_type: "organization"
|
90
|
+
)',
|
91
|
+
'webhooks = circleci_list_webhooks(
|
92
|
+
scope_id: "project-uuid",
|
93
|
+
scope_type: "project"
|
94
|
+
)
|
95
|
+
|
96
|
+
# Check if a specific webhook exists
|
97
|
+
has_slack_webhook = webhooks.any? { |webhook| webhook["url"].include?("hooks.slack.com") }
|
98
|
+
puts "Slack webhook is #{has_slack_webhook ? "configured" : "not configured"}"'
|
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,101 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/circle_ci_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
class CircleciRerunWorkflowAction < Action
|
7
|
+
def self.run(params)
|
8
|
+
UI.message("Rerunning CircleCI workflow via API v2...")
|
9
|
+
|
10
|
+
api_token = params[:api_token]
|
11
|
+
workflow_id = params[:workflow_id]
|
12
|
+
from_failed = params[:from_failed]
|
13
|
+
sparse_tree = params[:sparse_tree]
|
14
|
+
|
15
|
+
# Create request body
|
16
|
+
body = {}
|
17
|
+
body[:from_failed] = from_failed unless from_failed.nil?
|
18
|
+
body[:sparse_tree] = sparse_tree unless sparse_tree.nil?
|
19
|
+
|
20
|
+
# Make API request
|
21
|
+
result = Helper::CircleCiHelper.post_v2("workflow/#{workflow_id}/rerun", api_token, body)
|
22
|
+
|
23
|
+
UI.success("Successfully reran workflow with ID #{workflow_id}")
|
24
|
+
|
25
|
+
return result
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.description
|
29
|
+
"Reruns a workflow in CircleCI using API v2"
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.details
|
33
|
+
"This action reruns a specific workflow in CircleCI using the CircleCI API v2. You can choose to rerun the entire workflow or just the failed jobs."
|
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 rerun",
|
50
|
+
is_string: true,
|
51
|
+
optional: false),
|
52
|
+
FastlaneCore::ConfigItem.new(key: :from_failed,
|
53
|
+
env_name: "CIRCLE_CI_WORKFLOW_FROM_FAILED",
|
54
|
+
description: "Whether to rerun just the failed jobs (true) or all jobs (false)",
|
55
|
+
is_string: false,
|
56
|
+
default_value: true,
|
57
|
+
optional: true),
|
58
|
+
FastlaneCore::ConfigItem.new(key: :sparse_tree,
|
59
|
+
env_name: "CIRCLE_CI_WORKFLOW_SPARSE_TREE",
|
60
|
+
description: "If rerunning failed jobs, whether to rerun them as a sparse tree of only the failed jobs",
|
61
|
+
is_string: false,
|
62
|
+
default_value: false,
|
63
|
+
optional: true)
|
64
|
+
]
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.return_value
|
68
|
+
"Returns the API response with workflow rerun information."
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.authors
|
72
|
+
["crazymanish", "copilot"]
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.example_code
|
76
|
+
[
|
77
|
+
'circleci_rerun_workflow(
|
78
|
+
workflow_id: "1234-5678-90ab-cdef"
|
79
|
+
)',
|
80
|
+
'circleci_rerun_workflow(
|
81
|
+
workflow_id: "1234-5678-90ab-cdef",
|
82
|
+
from_failed: false # Rerun all jobs in the workflow
|
83
|
+
)',
|
84
|
+
'circleci_rerun_workflow(
|
85
|
+
workflow_id: "1234-5678-90ab-cdef",
|
86
|
+
from_failed: true,
|
87
|
+
sparse_tree: true # Rerun only the failed jobs and their upstream dependencies
|
88
|
+
)'
|
89
|
+
]
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.is_supported?(platform)
|
93
|
+
true
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.category
|
97
|
+
:ci
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|