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,160 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/circle_ci_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
CIRCLECI_CREATED_SCHEDULE_ID = :CIRCLECI_CREATED_SCHEDULE_ID
|
8
|
+
end
|
9
|
+
|
10
|
+
class CircleciCreatePipelineScheduleAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
UI.message("Creating CircleCI pipeline schedule via API v2...")
|
13
|
+
|
14
|
+
api_token = params[:api_token]
|
15
|
+
project_slug = params[:project_slug]
|
16
|
+
name = params[:name]
|
17
|
+
description = params[:description]
|
18
|
+
attribution_actor = params[:attribution_actor]
|
19
|
+
parameters = params[:parameters] || {}
|
20
|
+
timetable = params[:timetable]
|
21
|
+
branch = params[:branch]
|
22
|
+
|
23
|
+
# Create request body
|
24
|
+
body = {
|
25
|
+
name: name,
|
26
|
+
description: description,
|
27
|
+
attribution_actor: attribution_actor,
|
28
|
+
parameters: parameters,
|
29
|
+
timetable: timetable
|
30
|
+
}
|
31
|
+
|
32
|
+
# Add branch if specified
|
33
|
+
body[:branch] = branch if branch
|
34
|
+
|
35
|
+
# Make API request
|
36
|
+
result = Helper::CircleCiHelper.post_v2("project/#{project_slug}/schedule", api_token, body)
|
37
|
+
|
38
|
+
# Store values in lane context
|
39
|
+
Actions.lane_context[SharedValues::CIRCLECI_CREATED_SCHEDULE_ID] = result["id"]
|
40
|
+
|
41
|
+
UI.success("Successfully created pipeline schedule '#{name}' with ID #{result["id"]}")
|
42
|
+
|
43
|
+
return result
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.description
|
47
|
+
"Creates a new pipeline schedule for a CircleCI project using API v2"
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.details
|
51
|
+
"This action creates a new pipeline schedule for a specific CircleCI project using the CircleCI API v2. The schedule determines when pipelines will be automatically triggered."
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.available_options
|
55
|
+
[
|
56
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
57
|
+
env_name: "CIRCLE_CI_API_TOKEN",
|
58
|
+
description: "API Token for CircleCI API",
|
59
|
+
sensitive: true,
|
60
|
+
code_gen_sensitive: true,
|
61
|
+
is_string: true,
|
62
|
+
default_value: ENV["CIRCLE_CI_API_TOKEN"],
|
63
|
+
default_value_dynamic: true,
|
64
|
+
optional: false),
|
65
|
+
FastlaneCore::ConfigItem.new(key: :project_slug,
|
66
|
+
env_name: "CIRCLE_CI_PROJECT_SLUG",
|
67
|
+
description: "Project slug in the form of :vcs-type/:org-name/:project-name (e.g. github/myorg/myrepo)",
|
68
|
+
is_string: true,
|
69
|
+
default_value: ENV["CIRCLE_CI_PROJECT_SLUG"],
|
70
|
+
default_value_dynamic: true,
|
71
|
+
optional: false),
|
72
|
+
FastlaneCore::ConfigItem.new(key: :name,
|
73
|
+
env_name: "CIRCLE_CI_SCHEDULE_NAME",
|
74
|
+
description: "Name of the schedule",
|
75
|
+
is_string: true,
|
76
|
+
optional: false),
|
77
|
+
FastlaneCore::ConfigItem.new(key: :description,
|
78
|
+
env_name: "CIRCLE_CI_SCHEDULE_DESCRIPTION",
|
79
|
+
description: "Description of the schedule",
|
80
|
+
is_string: true,
|
81
|
+
optional: true),
|
82
|
+
FastlaneCore::ConfigItem.new(key: :attribution_actor,
|
83
|
+
env_name: "CIRCLE_CI_ATTRIBUTION_ACTOR",
|
84
|
+
description: "The attribution actor who will run the scheduled pipeline (e.g., 'current' for the current user)",
|
85
|
+
is_string: true,
|
86
|
+
default_value: "current",
|
87
|
+
optional: true),
|
88
|
+
FastlaneCore::ConfigItem.new(key: :parameters,
|
89
|
+
env_name: "CIRCLE_CI_SCHEDULE_PARAMETERS",
|
90
|
+
description: "Pipeline parameters, must match parameters defined in the pipeline configuration",
|
91
|
+
is_string: false,
|
92
|
+
default_value: {},
|
93
|
+
optional: true),
|
94
|
+
FastlaneCore::ConfigItem.new(key: :timetable,
|
95
|
+
env_name: "CIRCLE_CI_SCHEDULE_TIMETABLE",
|
96
|
+
description: "Timetable hash defining when the schedule should run (e.g., {per_hour: 1, hours_of_day: [0, 12], days_of_week: [1, 3, 5]})",
|
97
|
+
is_string: false,
|
98
|
+
optional: false),
|
99
|
+
FastlaneCore::ConfigItem.new(key: :branch,
|
100
|
+
env_name: "CIRCLE_CI_SCHEDULE_BRANCH",
|
101
|
+
description: "The branch to trigger a pipeline on",
|
102
|
+
is_string: true,
|
103
|
+
optional: true)
|
104
|
+
]
|
105
|
+
end
|
106
|
+
|
107
|
+
def self.output
|
108
|
+
[
|
109
|
+
['CIRCLECI_CREATED_SCHEDULE_ID', 'The ID of the created pipeline schedule']
|
110
|
+
]
|
111
|
+
end
|
112
|
+
|
113
|
+
def self.return_value
|
114
|
+
"Returns the full API response including the created schedule's details."
|
115
|
+
end
|
116
|
+
|
117
|
+
def self.authors
|
118
|
+
["crazymanish", "copilot"]
|
119
|
+
end
|
120
|
+
|
121
|
+
def self.example_code
|
122
|
+
[
|
123
|
+
'circleci_create_pipeline_schedule(
|
124
|
+
project_slug: "github/myorg/myrepo",
|
125
|
+
name: "Nightly Build",
|
126
|
+
description: "Runs every night at midnight",
|
127
|
+
timetable: {
|
128
|
+
per_hour: 1,
|
129
|
+
hours_of_day: [0],
|
130
|
+
days_of_week: [1, 2, 3, 4, 5]
|
131
|
+
},
|
132
|
+
branch: "main",
|
133
|
+
parameters: {
|
134
|
+
"deploy_env" => "staging"
|
135
|
+
}
|
136
|
+
)',
|
137
|
+
'circleci_create_pipeline_schedule(
|
138
|
+
project_slug: "github/myorg/myrepo",
|
139
|
+
name: "Weekly Release",
|
140
|
+
description: "Runs every Friday at 2pm",
|
141
|
+
timetable: {
|
142
|
+
per_hour: 1,
|
143
|
+
hours_of_day: [14],
|
144
|
+
days_of_week: [5]
|
145
|
+
},
|
146
|
+
branch: "release"
|
147
|
+
)'
|
148
|
+
]
|
149
|
+
end
|
150
|
+
|
151
|
+
def self.is_supported?(platform)
|
152
|
+
true
|
153
|
+
end
|
154
|
+
|
155
|
+
def self.category
|
156
|
+
:ci
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/circle_ci_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
CIRCLECI_PROJECT = :CIRCLECI_PROJECT
|
8
|
+
end
|
9
|
+
|
10
|
+
class CircleciCreateProjectAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
UI.message("Creating 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.post_v2("project/#{project_slug}/follow", api_token)
|
19
|
+
|
20
|
+
# Store values in lane context
|
21
|
+
Actions.lane_context[SharedValues::CIRCLECI_PROJECT] = result
|
22
|
+
|
23
|
+
UI.success("Successfully created CircleCI project #{project_slug}")
|
24
|
+
|
25
|
+
return result
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.description
|
29
|
+
"Creates a new CircleCI project using API v2"
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.details
|
33
|
+
"This action creates a new CircleCI project by following a repository using the CircleCI API v2. This makes the repository available for building on CircleCI."
|
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
|
+
optional: false)
|
52
|
+
]
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.output
|
56
|
+
[
|
57
|
+
['CIRCLECI_PROJECT', 'A hash containing the created project details']
|
58
|
+
]
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.return_value
|
62
|
+
"Returns a hash containing the created project details."
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.authors
|
66
|
+
["crazymanish", "copilot"]
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.example_code
|
70
|
+
[
|
71
|
+
'circleci_create_project(
|
72
|
+
project_slug: "github/myorg/new-repo"
|
73
|
+
)',
|
74
|
+
'# Create a new CircleCI project and immediately trigger a build
|
75
|
+
project = circleci_create_project(
|
76
|
+
project_slug: "github/myorg/new-repo"
|
77
|
+
)
|
78
|
+
|
79
|
+
# Trigger first pipeline
|
80
|
+
pipeline = circleci_trigger_pipeline(
|
81
|
+
project_slug: "github/myorg/new-repo",
|
82
|
+
branch: "main"
|
83
|
+
)
|
84
|
+
|
85
|
+
UI.message("Started pipeline ##{pipeline["number"]} for the new project")
|
86
|
+
|
87
|
+
# Wait for the pipeline to complete
|
88
|
+
circleci_wait_for_pipeline(
|
89
|
+
project_slug: "github/myorg/new-repo",
|
90
|
+
pipeline_id: pipeline["id"],
|
91
|
+
timeout: 1800 # 30 minutes
|
92
|
+
)'
|
93
|
+
]
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.is_supported?(platform)
|
97
|
+
true
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.category
|
101
|
+
:ci
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,155 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/circle_ci_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
CIRCLECI_CREATED_WEBHOOK_ID = :CIRCLECI_CREATED_WEBHOOK_ID
|
8
|
+
end
|
9
|
+
|
10
|
+
class CircleciCreateWebhookAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
UI.message("Creating CircleCI webhook via API v2...")
|
13
|
+
|
14
|
+
api_token = params[:api_token]
|
15
|
+
name = params[:name]
|
16
|
+
url = params[:url]
|
17
|
+
events = params[:events]
|
18
|
+
signing_secret = params[:signing_secret]
|
19
|
+
verify_tls = params[:verify_tls]
|
20
|
+
scope_id = params[:scope_id]
|
21
|
+
scope_type = params[:scope_type]
|
22
|
+
|
23
|
+
# Create request body
|
24
|
+
body = {
|
25
|
+
name: name,
|
26
|
+
url: url,
|
27
|
+
events: events,
|
28
|
+
verify_tls: verify_tls,
|
29
|
+
"signing-secret": signing_secret,
|
30
|
+
scope: {
|
31
|
+
id: scope_id,
|
32
|
+
type: scope_type
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
# Make API request
|
37
|
+
result = Helper::CircleCiHelper.post_v2("webhook", api_token, body)
|
38
|
+
|
39
|
+
# Store values in lane context
|
40
|
+
Actions.lane_context[SharedValues::CIRCLECI_CREATED_WEBHOOK_ID] = result["id"]
|
41
|
+
|
42
|
+
UI.success("Successfully created webhook '#{name}' with ID #{result["id"]}")
|
43
|
+
|
44
|
+
return result
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.description
|
48
|
+
"Creates a new webhook for a CircleCI project or organization using API v2"
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.details
|
52
|
+
"This action creates a new webhook for a specific CircleCI project or organization using the CircleCI API v2. Webhooks allow external services to be notified of CircleCI events."
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.available_options
|
56
|
+
[
|
57
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
58
|
+
env_name: "CIRCLE_CI_API_TOKEN",
|
59
|
+
description: "API Token for CircleCI API",
|
60
|
+
sensitive: true,
|
61
|
+
code_gen_sensitive: true,
|
62
|
+
is_string: true,
|
63
|
+
default_value: ENV["CIRCLE_CI_API_TOKEN"],
|
64
|
+
default_value_dynamic: true,
|
65
|
+
optional: false),
|
66
|
+
FastlaneCore::ConfigItem.new(key: :name,
|
67
|
+
env_name: "CIRCLE_CI_WEBHOOK_NAME",
|
68
|
+
description: "Name of the webhook",
|
69
|
+
is_string: true,
|
70
|
+
optional: false),
|
71
|
+
FastlaneCore::ConfigItem.new(key: :url,
|
72
|
+
env_name: "CIRCLE_CI_WEBHOOK_URL",
|
73
|
+
description: "URL to send the webhook to",
|
74
|
+
is_string: true,
|
75
|
+
optional: false),
|
76
|
+
FastlaneCore::ConfigItem.new(key: :events,
|
77
|
+
env_name: "CIRCLE_CI_WEBHOOK_EVENTS",
|
78
|
+
description: "Array of event types to trigger the webhook (e.g., ['workflow-completed', 'job-completed'])",
|
79
|
+
is_string: false,
|
80
|
+
optional: false),
|
81
|
+
FastlaneCore::ConfigItem.new(key: :signing_secret,
|
82
|
+
env_name: "CIRCLE_CI_WEBHOOK_SIGNING_SECRET",
|
83
|
+
description: "Secret used to verify webhook signatures",
|
84
|
+
is_string: true,
|
85
|
+
sensitive: true,
|
86
|
+
code_gen_sensitive: true,
|
87
|
+
optional: false),
|
88
|
+
FastlaneCore::ConfigItem.new(key: :verify_tls,
|
89
|
+
env_name: "CIRCLE_CI_WEBHOOK_VERIFY_TLS",
|
90
|
+
description: "Whether to verify TLS certificates when sending webhooks",
|
91
|
+
is_string: false,
|
92
|
+
default_value: true,
|
93
|
+
optional: true),
|
94
|
+
FastlaneCore::ConfigItem.new(key: :scope_id,
|
95
|
+
env_name: "CIRCLE_CI_WEBHOOK_SCOPE_ID",
|
96
|
+
description: "The ID of the project or organization to create the webhook for",
|
97
|
+
is_string: true,
|
98
|
+
optional: false),
|
99
|
+
FastlaneCore::ConfigItem.new(key: :scope_type,
|
100
|
+
env_name: "CIRCLE_CI_WEBHOOK_SCOPE_TYPE",
|
101
|
+
description: "The type of scope (either 'project' or 'organization')",
|
102
|
+
is_string: true,
|
103
|
+
verify_block: proc do |value|
|
104
|
+
UI.user_error!("Scope type must be either 'project' or 'organization'") unless ['project', 'organization'].include?(value)
|
105
|
+
end,
|
106
|
+
optional: false)
|
107
|
+
]
|
108
|
+
end
|
109
|
+
|
110
|
+
def self.output
|
111
|
+
[
|
112
|
+
['CIRCLECI_CREATED_WEBHOOK_ID', 'The ID of the created webhook']
|
113
|
+
]
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.return_value
|
117
|
+
"Returns the full API response including the created webhook's details."
|
118
|
+
end
|
119
|
+
|
120
|
+
def self.authors
|
121
|
+
["crazymanish", "copilot"]
|
122
|
+
end
|
123
|
+
|
124
|
+
def self.example_code
|
125
|
+
[
|
126
|
+
'circleci_create_webhook(
|
127
|
+
name: "Slack Notification",
|
128
|
+
url: "https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK",
|
129
|
+
events: ["workflow-completed", "job-failed"],
|
130
|
+
signing_secret: "your-secret-key",
|
131
|
+
scope_id: "project-uuid",
|
132
|
+
scope_type: "project"
|
133
|
+
)',
|
134
|
+
'circleci_create_webhook(
|
135
|
+
name: "Deployment Notification",
|
136
|
+
url: "https://example.com/deployment-webhook",
|
137
|
+
events: ["workflow-completed"],
|
138
|
+
signing_secret: "your-secret-key",
|
139
|
+
verify_tls: false,
|
140
|
+
scope_id: "organization-uuid",
|
141
|
+
scope_type: "organization"
|
142
|
+
)'
|
143
|
+
]
|
144
|
+
end
|
145
|
+
|
146
|
+
def self.is_supported?(platform)
|
147
|
+
true
|
148
|
+
end
|
149
|
+
|
150
|
+
def self.category
|
151
|
+
:ci
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/circle_ci_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
class CircleciDeleteCheckoutKeyAction < Action
|
7
|
+
def self.run(params)
|
8
|
+
UI.message("Deleting CircleCI project checkout key via API v2...")
|
9
|
+
|
10
|
+
api_token = params[:api_token]
|
11
|
+
project_slug = params[:project_slug]
|
12
|
+
fingerprint = params[:fingerprint]
|
13
|
+
|
14
|
+
# Make API request
|
15
|
+
result = Helper::CircleCiHelper.delete_v2("project/#{project_slug}/checkout-key/#{fingerprint}", api_token)
|
16
|
+
|
17
|
+
UI.success("Successfully deleted checkout key with fingerprint #{fingerprint} from project #{project_slug}")
|
18
|
+
|
19
|
+
return result
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.description
|
23
|
+
"Deletes a checkout key from a CircleCI project using API v2"
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.details
|
27
|
+
"This action deletes a specific checkout key from a CircleCI project using the CircleCI API v2. You need to provide the fingerprint of the key you want to delete."
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.available_options
|
31
|
+
[
|
32
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
33
|
+
env_name: "CIRCLE_CI_API_TOKEN",
|
34
|
+
description: "API Token for CircleCI API",
|
35
|
+
sensitive: true,
|
36
|
+
code_gen_sensitive: true,
|
37
|
+
is_string: true,
|
38
|
+
default_value: ENV["CIRCLE_CI_API_TOKEN"],
|
39
|
+
default_value_dynamic: true,
|
40
|
+
optional: false),
|
41
|
+
FastlaneCore::ConfigItem.new(key: :project_slug,
|
42
|
+
env_name: "CIRCLE_CI_PROJECT_SLUG",
|
43
|
+
description: "Project slug in the form of :vcs-type/:org-name/:project-name (e.g. github/myorg/myrepo)",
|
44
|
+
is_string: true,
|
45
|
+
default_value: ENV["CIRCLE_CI_PROJECT_SLUG"],
|
46
|
+
default_value_dynamic: true,
|
47
|
+
optional: false),
|
48
|
+
FastlaneCore::ConfigItem.new(key: :fingerprint,
|
49
|
+
description: "The fingerprint of the checkout key to delete",
|
50
|
+
is_string: true,
|
51
|
+
optional: false)
|
52
|
+
]
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.return_value
|
56
|
+
"Returns a hash with a 'message' key indicating success or failure."
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.authors
|
60
|
+
["crazymanish", "copilot"]
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.example_code
|
64
|
+
[
|
65
|
+
'circleci_delete_checkout_key(
|
66
|
+
project_slug: "gh/MyOrg/my-project",
|
67
|
+
fingerprint: "c9:0b:1c:4f:d5:65:56:b9:ad:88:f9:81:2b:37:74:2f"
|
68
|
+
)',
|
69
|
+
'# Get keys first, then delete one
|
70
|
+
keys = circleci_get_checkout_keys(
|
71
|
+
project_slug: "gh/MyOrg/my-project"
|
72
|
+
)
|
73
|
+
|
74
|
+
# Delete the first key
|
75
|
+
if keys["items"].any?
|
76
|
+
circleci_delete_checkout_key(
|
77
|
+
project_slug: "gh/MyOrg/my-project",
|
78
|
+
fingerprint: keys["items"].first["fingerprint"]
|
79
|
+
)
|
80
|
+
end'
|
81
|
+
]
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.is_supported?(platform)
|
85
|
+
true
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.category
|
89
|
+
:ci
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/circle_ci_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
class CircleciDeleteContextEnvVarAction < Action
|
7
|
+
def self.run(params)
|
8
|
+
UI.message("Deleting environment variable from CircleCI context via API v2...")
|
9
|
+
|
10
|
+
api_token = params[:api_token]
|
11
|
+
context_id = params[:context_id]
|
12
|
+
env_var_name = params[:env_var_name]
|
13
|
+
|
14
|
+
# Make API request
|
15
|
+
begin
|
16
|
+
Helper::CircleCiHelper.delete_v2("context/#{context_id}/environment-variable/#{env_var_name}", api_token)
|
17
|
+
UI.success("Successfully deleted environment variable '#{env_var_name}' from context #{context_id}")
|
18
|
+
return true
|
19
|
+
rescue => e
|
20
|
+
UI.error("Failed to delete environment variable: #{e.message}")
|
21
|
+
return false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.description
|
26
|
+
"Deletes an environment variable from a CircleCI context using API v2"
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.details
|
30
|
+
"This action deletes an environment variable from a specific CircleCI context using the CircleCI API v2."
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.available_options
|
34
|
+
[
|
35
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
36
|
+
env_name: "CIRCLE_CI_API_TOKEN",
|
37
|
+
description: "API Token for CircleCI API",
|
38
|
+
sensitive: true,
|
39
|
+
code_gen_sensitive: true,
|
40
|
+
is_string: true,
|
41
|
+
default_value: ENV["CIRCLE_CI_API_TOKEN"],
|
42
|
+
default_value_dynamic: true,
|
43
|
+
optional: false),
|
44
|
+
FastlaneCore::ConfigItem.new(key: :context_id,
|
45
|
+
env_name: "CIRCLE_CI_CONTEXT_ID",
|
46
|
+
description: "The ID of the context to delete the environment variable from",
|
47
|
+
is_string: true,
|
48
|
+
optional: false),
|
49
|
+
FastlaneCore::ConfigItem.new(key: :env_var_name,
|
50
|
+
env_name: "CIRCLE_CI_ENV_VAR_NAME",
|
51
|
+
description: "The name of the environment variable to delete",
|
52
|
+
is_string: true,
|
53
|
+
optional: false)
|
54
|
+
]
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.return_value
|
58
|
+
"Returns true if the deletion was successful, false otherwise."
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.authors
|
62
|
+
["crazymanish", "copilot"]
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.example_code
|
66
|
+
[
|
67
|
+
'circleci_delete_context_env_var(
|
68
|
+
context_id: "context-uuid",
|
69
|
+
env_var_name: "DEPRECATED_API_KEY"
|
70
|
+
)',
|
71
|
+
'# Clean up old environment variables from a context
|
72
|
+
contexts = circleci_list_contexts(
|
73
|
+
owner_slug: "github/myorg"
|
74
|
+
)
|
75
|
+
|
76
|
+
# Find the development context
|
77
|
+
dev_context = contexts.find { |c| c["name"] == "development" }
|
78
|
+
|
79
|
+
if dev_context
|
80
|
+
# Get current environment variables
|
81
|
+
env_vars = circleci_get_context_env_vars(
|
82
|
+
context_id: dev_context["id"]
|
83
|
+
)
|
84
|
+
|
85
|
+
# Remove deprecated variables
|
86
|
+
deprecated_vars = ["OLD_API_URL", "LEGACY_TOKEN", "UNUSED_VAR"]
|
87
|
+
|
88
|
+
deprecated_vars.each do |var_name|
|
89
|
+
if env_vars.any? { |var| var["variable"] == var_name }
|
90
|
+
circleci_delete_context_env_var(
|
91
|
+
context_id: dev_context["id"],
|
92
|
+
env_var_name: var_name
|
93
|
+
)
|
94
|
+
UI.important("Removed deprecated variable: #{var_name}")
|
95
|
+
end
|
96
|
+
end
|
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
|