fastlane-plugin-circle_ci 0.1.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/actions/get_circle_ci_artifacts.rb +1 -1
- data/lib/fastlane/plugin/circle_ci/actions/get_circle_ci_build_status.rb +1 -1
- data/lib/fastlane/plugin/circle_ci/actions/trigger_circle_ci_job.rb +1 -1
- data/lib/fastlane/plugin/circle_ci/helper/circle_ci_helper.rb +106 -5
- data/lib/fastlane/plugin/circle_ci/version.rb +1 -1
- metadata +99 -7
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/circle_ci_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
class CircleciSetEnvVarAction < Action
|
7
|
+
def self.run(params)
|
8
|
+
UI.message("Setting environment variable for CircleCI project via API v2...")
|
9
|
+
|
10
|
+
api_token = params[:api_token]
|
11
|
+
project_slug = params[:project_slug]
|
12
|
+
name = params[:name]
|
13
|
+
value = params[:value]
|
14
|
+
|
15
|
+
# Create request body
|
16
|
+
body = {
|
17
|
+
name: name,
|
18
|
+
value: value
|
19
|
+
}
|
20
|
+
|
21
|
+
# Make API request
|
22
|
+
result = Helper::CircleCiHelper.post_v2("project/#{project_slug}/envvar", api_token, body)
|
23
|
+
|
24
|
+
UI.success("Successfully set environment variable '#{name}' for project #{project_slug}")
|
25
|
+
|
26
|
+
return result
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.description
|
30
|
+
"Sets an environment variable for a CircleCI project using API v2"
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.details
|
34
|
+
"This action sets an environment variable for a specific CircleCI project 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: :name,
|
56
|
+
env_name: "CIRCLE_CI_ENV_VAR_NAME",
|
57
|
+
description: "Name of the environment variable to set",
|
58
|
+
is_string: true,
|
59
|
+
optional: false),
|
60
|
+
FastlaneCore::ConfigItem.new(key: :value,
|
61
|
+
env_name: "CIRCLE_CI_ENV_VAR_VALUE",
|
62
|
+
description: "Value of the environment variable to set",
|
63
|
+
sensitive: true,
|
64
|
+
code_gen_sensitive: true,
|
65
|
+
is_string: true,
|
66
|
+
optional: false)
|
67
|
+
]
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.return_value
|
71
|
+
"Returns the API response containing the name and masked value of the set environment variable."
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.authors
|
75
|
+
["crazymanish", "copilot"]
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.example_code
|
79
|
+
[
|
80
|
+
'circleci_set_env_var(
|
81
|
+
project_slug: "github/myorg/myrepo",
|
82
|
+
name: "API_KEY",
|
83
|
+
value: "secret-api-key"
|
84
|
+
)',
|
85
|
+
'circleci_set_env_var(
|
86
|
+
project_slug: "github/myorg/myrepo",
|
87
|
+
name: "DEPLOY_ENVIRONMENT",
|
88
|
+
value: "production"
|
89
|
+
)'
|
90
|
+
]
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.is_supported?(platform)
|
94
|
+
true
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.category
|
98
|
+
:ci
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/circle_ci_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
CIRCLECI_PIPELINE_ID = :CIRCLECI_PIPELINE_ID
|
8
|
+
CIRCLECI_PIPELINE_NUMBER = :CIRCLECI_PIPELINE_NUMBER
|
9
|
+
CIRCLECI_PIPELINE_URL = :CIRCLECI_PIPELINE_URL
|
10
|
+
end
|
11
|
+
|
12
|
+
class CircleciTriggerPipelineAction < Action
|
13
|
+
def self.run(params)
|
14
|
+
UI.message("Triggering CircleCI pipeline via API v2...")
|
15
|
+
|
16
|
+
api_token = params[:api_token]
|
17
|
+
project_slug = params[:project_slug]
|
18
|
+
branch = params[:branch]
|
19
|
+
parameters = params[:parameters] || {}
|
20
|
+
|
21
|
+
# Create request body
|
22
|
+
body = {
|
23
|
+
branch: branch
|
24
|
+
}
|
25
|
+
|
26
|
+
# Add parameters if they exist
|
27
|
+
body[:parameters] = parameters unless parameters.empty?
|
28
|
+
|
29
|
+
# Make API request
|
30
|
+
result = Helper::CircleCiHelper.post_v2("project/#{project_slug}/pipeline", api_token, body)
|
31
|
+
|
32
|
+
# Store values in lane context
|
33
|
+
Actions.lane_context[SharedValues::CIRCLECI_PIPELINE_ID] = result["id"]
|
34
|
+
Actions.lane_context[SharedValues::CIRCLECI_PIPELINE_NUMBER] = result["number"]
|
35
|
+
|
36
|
+
# Create pipeline URL
|
37
|
+
vcs_info = project_slug.split('/')
|
38
|
+
pipeline_url = "https://app.circleci.com/pipelines/#{vcs_info[0]}/#{vcs_info[1]}/#{vcs_info[2]}/#{result["number"]}"
|
39
|
+
Actions.lane_context[SharedValues::CIRCLECI_PIPELINE_URL] = pipeline_url
|
40
|
+
|
41
|
+
UI.success("Successfully triggered CircleCI pipeline ##{result["number"]} with ID #{result["id"]}")
|
42
|
+
UI.success("Pipeline URL: #{pipeline_url}")
|
43
|
+
|
44
|
+
return result
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.description
|
48
|
+
"Triggers a CircleCI pipeline using API v2"
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.details
|
52
|
+
"This action triggers a CircleCI pipeline using the CircleCI API v2. It allows you to specify branch and parameters for the pipeline run."
|
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: :project_slug,
|
67
|
+
env_name: "CIRCLE_CI_PROJECT_SLUG",
|
68
|
+
description: "Project slug in the form of :vcs-type/:org-name/:project-name (e.g. github/myorg/myrepo)",
|
69
|
+
is_string: true,
|
70
|
+
default_value: ENV["CIRCLE_CI_PROJECT_SLUG"],
|
71
|
+
default_value_dynamic: true,
|
72
|
+
optional: false),
|
73
|
+
FastlaneCore::ConfigItem.new(key: :branch,
|
74
|
+
env_name: "CIRCLE_CI_BRANCH",
|
75
|
+
description: "The branch to trigger a pipeline on",
|
76
|
+
is_string: true,
|
77
|
+
default_value: "main",
|
78
|
+
optional: false),
|
79
|
+
FastlaneCore::ConfigItem.new(key: :parameters,
|
80
|
+
env_name: "CIRCLE_CI_PIPELINE_PARAMETERS",
|
81
|
+
description: "Pipeline parameters, must match parameters defined in the pipeline configuration",
|
82
|
+
is_string: false,
|
83
|
+
default_value: {},
|
84
|
+
optional: true)
|
85
|
+
]
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.output
|
89
|
+
[
|
90
|
+
['CIRCLECI_PIPELINE_ID', 'The ID of the triggered pipeline'],
|
91
|
+
['CIRCLECI_PIPELINE_NUMBER', 'The number of the triggered pipeline'],
|
92
|
+
['CIRCLECI_PIPELINE_URL', 'The URL of the triggered pipeline']
|
93
|
+
]
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.return_value
|
97
|
+
"Returns the full API response from CircleCI API"
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.authors
|
101
|
+
["crazymanish", "copilot"]
|
102
|
+
end
|
103
|
+
|
104
|
+
def self.example_code
|
105
|
+
[
|
106
|
+
'circleci_trigger_pipeline(
|
107
|
+
project_slug: "github/myorg/myrepo",
|
108
|
+
branch: "main",
|
109
|
+
parameters: {
|
110
|
+
"deploy_env" => "staging",
|
111
|
+
"run_integration_tests" => true
|
112
|
+
}
|
113
|
+
)',
|
114
|
+
'circleci_trigger_pipeline(
|
115
|
+
project_slug: "github/myorg/myrepo",
|
116
|
+
branch: "feature/my-branch"
|
117
|
+
)'
|
118
|
+
]
|
119
|
+
end
|
120
|
+
|
121
|
+
def self.is_supported?(platform)
|
122
|
+
true
|
123
|
+
end
|
124
|
+
|
125
|
+
def self.category
|
126
|
+
:ci
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/circle_ci_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
CIRCLECI_UPDATED_PIPELINE_DEFINITION = :CIRCLECI_UPDATED_PIPELINE_DEFINITION
|
8
|
+
end
|
9
|
+
|
10
|
+
class CircleciUpdatePipelineDefinitionAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
UI.message("Updating CircleCI pipeline definition 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
|
+
# Build the request body with only provided parameters
|
19
|
+
body = {}
|
20
|
+
body["name"] = params[:name] if params[:name]
|
21
|
+
body["description"] = params[:description] if params[:description]
|
22
|
+
body["config_source"] = params[:config_source] if params[:config_source]
|
23
|
+
|
24
|
+
# Make API request
|
25
|
+
result = Helper::CircleCiHelper.patch_v2("projects/#{project_id}/pipeline-definitions/#{pipeline_definition_id}", api_token, body)
|
26
|
+
|
27
|
+
# Store values in lane context
|
28
|
+
Actions.lane_context[SharedValues::CIRCLECI_UPDATED_PIPELINE_DEFINITION] = result
|
29
|
+
|
30
|
+
UI.success("Successfully updated pipeline definition with ID #{pipeline_definition_id}")
|
31
|
+
|
32
|
+
return result
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.description
|
36
|
+
"Updates a pipeline definition in CircleCI using API v2"
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.details
|
40
|
+
"This action updates an existing pipeline definition in CircleCI using the CircleCI API v2. Currently only supported for pipeline definitions where config_source.provider is github_app or bitbucket_dc."
|
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_id,
|
55
|
+
env_name: "CIRCLE_CI_PROJECT_ID",
|
56
|
+
description: "The ID of the CircleCI project",
|
57
|
+
is_string: true,
|
58
|
+
optional: false),
|
59
|
+
FastlaneCore::ConfigItem.new(key: :pipeline_definition_id,
|
60
|
+
description: "The ID of the pipeline definition to update",
|
61
|
+
is_string: true,
|
62
|
+
optional: false),
|
63
|
+
FastlaneCore::ConfigItem.new(key: :name,
|
64
|
+
description: "New name for the pipeline definition",
|
65
|
+
is_string: true,
|
66
|
+
optional: true),
|
67
|
+
FastlaneCore::ConfigItem.new(key: :description,
|
68
|
+
description: "New description for the pipeline definition",
|
69
|
+
is_string: true,
|
70
|
+
optional: true),
|
71
|
+
FastlaneCore::ConfigItem.new(key: :config_source,
|
72
|
+
description: "New configuration source for the pipeline definition",
|
73
|
+
type: Hash,
|
74
|
+
optional: true,
|
75
|
+
verify_block: proc do |value|
|
76
|
+
UI.user_error!("config_source must contain 'provider'") unless value["provider"]
|
77
|
+
end)
|
78
|
+
]
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.output
|
82
|
+
[
|
83
|
+
['CIRCLECI_UPDATED_PIPELINE_DEFINITION', 'A hash containing the updated pipeline definition information']
|
84
|
+
]
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.return_value
|
88
|
+
"Returns a hash containing the updated pipeline definition information."
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.authors
|
92
|
+
["crazymanish", "copilot"]
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.example_code
|
96
|
+
[
|
97
|
+
'circleci_update_pipeline_definition(
|
98
|
+
project_id: "01234567-89ab-cdef-0123-456789abcdef",
|
99
|
+
pipeline_definition_id: "fedcba98-7654-3210-fedc-ba9876543210",
|
100
|
+
name: "Updated Pipeline Definition Name"
|
101
|
+
)',
|
102
|
+
'updated_definition = circleci_update_pipeline_definition(
|
103
|
+
project_id: "01234567-89ab-cdef-0123-456789abcdef",
|
104
|
+
pipeline_definition_id: "fedcba98-7654-3210-fedc-ba9876543210",
|
105
|
+
description: "Updated pipeline definition description",
|
106
|
+
config_source: {
|
107
|
+
"provider" => "github_app",
|
108
|
+
"config_path" => ".circleci/updated-config.yml",
|
109
|
+
"branch" => "feature/new-branch"
|
110
|
+
}
|
111
|
+
)
|
112
|
+
|
113
|
+
# Use the updated pipeline definition
|
114
|
+
UI.message("Updated definition name: #{updated_definition["name"]}")'
|
115
|
+
]
|
116
|
+
end
|
117
|
+
|
118
|
+
def self.is_supported?(platform)
|
119
|
+
true
|
120
|
+
end
|
121
|
+
|
122
|
+
def self.category
|
123
|
+
:ci
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/circle_ci_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
CIRCLECI_UPDATED_SCHEDULE = :CIRCLECI_UPDATED_SCHEDULE
|
8
|
+
end
|
9
|
+
|
10
|
+
class CircleciUpdatePipelineScheduleAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
UI.message("Updating CircleCI pipeline schedule via API v2...")
|
13
|
+
|
14
|
+
api_token = params[:api_token]
|
15
|
+
schedule_id = params[:schedule_id]
|
16
|
+
|
17
|
+
# Build the request body with only provided parameters
|
18
|
+
body = {}
|
19
|
+
body["description"] = params[:description] if params[:description]
|
20
|
+
body["name"] = params[:name] if params[:name]
|
21
|
+
body["parameters"] = params[:parameters] if params[:parameters]
|
22
|
+
body["timetable"] = params[:timetable] if params[:timetable]
|
23
|
+
body["attribution-actor"] = params[:attribution_actor] if params[:attribution_actor]
|
24
|
+
body["active"] = params[:active] unless params[:active].nil?
|
25
|
+
|
26
|
+
# Make API request
|
27
|
+
result = Helper::CircleCiHelper.patch_v2("schedule/#{schedule_id}", api_token, body)
|
28
|
+
|
29
|
+
# Store values in lane context
|
30
|
+
Actions.lane_context[SharedValues::CIRCLECI_UPDATED_SCHEDULE] = result
|
31
|
+
|
32
|
+
UI.success("Successfully updated pipeline schedule with ID #{schedule_id}")
|
33
|
+
|
34
|
+
return result
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.description
|
38
|
+
"Updates a pipeline schedule in CircleCI using API v2"
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.details
|
42
|
+
"This action updates an existing pipeline schedule in CircleCI using the CircleCI API v2. You can update various properties such as name, description, parameters, and timetable."
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.available_options
|
46
|
+
[
|
47
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
48
|
+
env_name: "CIRCLE_CI_API_TOKEN",
|
49
|
+
description: "API Token for CircleCI API",
|
50
|
+
sensitive: true,
|
51
|
+
code_gen_sensitive: true,
|
52
|
+
is_string: true,
|
53
|
+
default_value: ENV["CIRCLE_CI_API_TOKEN"],
|
54
|
+
default_value_dynamic: true,
|
55
|
+
optional: false),
|
56
|
+
FastlaneCore::ConfigItem.new(key: :schedule_id,
|
57
|
+
description: "The UUID of the schedule to update",
|
58
|
+
is_string: true,
|
59
|
+
optional: false),
|
60
|
+
FastlaneCore::ConfigItem.new(key: :description,
|
61
|
+
description: "Description of the schedule",
|
62
|
+
is_string: true,
|
63
|
+
optional: true),
|
64
|
+
FastlaneCore::ConfigItem.new(key: :name,
|
65
|
+
description: "Name of the schedule",
|
66
|
+
is_string: true,
|
67
|
+
optional: true),
|
68
|
+
FastlaneCore::ConfigItem.new(key: :parameters,
|
69
|
+
description: "Pipeline parameters (e.g. branch, tag)",
|
70
|
+
type: Hash,
|
71
|
+
optional: true),
|
72
|
+
FastlaneCore::ConfigItem.new(key: :timetable,
|
73
|
+
description: "Timetable definition for the schedule (e.g. hours, days-of-week, etc.)",
|
74
|
+
type: Hash,
|
75
|
+
optional: true),
|
76
|
+
FastlaneCore::ConfigItem.new(key: :attribution_actor,
|
77
|
+
description: "The attribution-actor field for the scheduled pipeline",
|
78
|
+
is_string: true,
|
79
|
+
optional: true),
|
80
|
+
FastlaneCore::ConfigItem.new(key: :active,
|
81
|
+
description: "Whether the schedule is active",
|
82
|
+
is_string: false,
|
83
|
+
optional: true)
|
84
|
+
]
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.output
|
88
|
+
[
|
89
|
+
['CIRCLECI_UPDATED_SCHEDULE', 'A hash containing the updated schedule information']
|
90
|
+
]
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.return_value
|
94
|
+
"Returns a hash containing the updated schedule information."
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.authors
|
98
|
+
["crazymanish", "copilot"]
|
99
|
+
end
|
100
|
+
|
101
|
+
def self.example_code
|
102
|
+
[
|
103
|
+
'circleci_update_pipeline_schedule(
|
104
|
+
schedule_id: "8a3eb5ac-8666-451b-8bfc-1ee10e46c81e",
|
105
|
+
name: "Updated Nightly Build",
|
106
|
+
description: "Runs every night at midnight",
|
107
|
+
parameters: {
|
108
|
+
"branch" => "main"
|
109
|
+
},
|
110
|
+
active: false
|
111
|
+
)',
|
112
|
+
'# Get a more detailed timetable
|
113
|
+
updated_schedule = circleci_update_pipeline_schedule(
|
114
|
+
schedule_id: "8a3eb5ac-8666-451b-8bfc-1ee10e46c81e",
|
115
|
+
timetable: {
|
116
|
+
"per-hour" => 1,
|
117
|
+
"hours-of-day" => [0, 12],
|
118
|
+
"days-of-week" => ["MON", "WED", "FRI"],
|
119
|
+
"time-zone" => "America/New_York"
|
120
|
+
}
|
121
|
+
)'
|
122
|
+
]
|
123
|
+
end
|
124
|
+
|
125
|
+
def self.is_supported?(platform)
|
126
|
+
true
|
127
|
+
end
|
128
|
+
|
129
|
+
def self.category
|
130
|
+
:ci
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
@@ -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_UPDATED_TRIGGER = :CIRCLECI_UPDATED_TRIGGER
|
8
|
+
end
|
9
|
+
|
10
|
+
class CircleciUpdateTriggerAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
UI.message("Updating CircleCI trigger via API v2...")
|
13
|
+
|
14
|
+
api_token = params[:api_token]
|
15
|
+
project_id = params[:project_id]
|
16
|
+
trigger_id = params[:trigger_id]
|
17
|
+
|
18
|
+
# Build the request body with only provided parameters
|
19
|
+
body = {}
|
20
|
+
body["description"] = params[:description] if params[:description]
|
21
|
+
body["config"] = params[:config] if params[:config]
|
22
|
+
|
23
|
+
# Make API request
|
24
|
+
result = Helper::CircleCiHelper.patch_v2("projects/#{project_id}/triggers/#{trigger_id}", api_token, body)
|
25
|
+
|
26
|
+
# Store values in lane context
|
27
|
+
Actions.lane_context[SharedValues::CIRCLECI_UPDATED_TRIGGER] = result
|
28
|
+
|
29
|
+
UI.success("Successfully updated trigger with ID #{trigger_id}")
|
30
|
+
|
31
|
+
return result
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.description
|
35
|
+
"Updates a trigger in CircleCI using API v2"
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.details
|
39
|
+
"This action updates an existing trigger in CircleCI using the CircleCI API v2. You can update the description and configuration of the trigger."
|
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_id,
|
54
|
+
env_name: "CIRCLE_CI_PROJECT_ID",
|
55
|
+
description: "The ID of the CircleCI project",
|
56
|
+
is_string: true,
|
57
|
+
optional: false),
|
58
|
+
FastlaneCore::ConfigItem.new(key: :trigger_id,
|
59
|
+
description: "The ID of the trigger to update",
|
60
|
+
is_string: true,
|
61
|
+
optional: false),
|
62
|
+
FastlaneCore::ConfigItem.new(key: :description,
|
63
|
+
description: "Updated description for the trigger",
|
64
|
+
is_string: true,
|
65
|
+
optional: true),
|
66
|
+
FastlaneCore::ConfigItem.new(key: :config,
|
67
|
+
description: "Updated configuration for the trigger (varies by trigger type)",
|
68
|
+
type: Hash,
|
69
|
+
optional: true)
|
70
|
+
]
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.output
|
74
|
+
[
|
75
|
+
['CIRCLECI_UPDATED_TRIGGER', 'A hash containing the updated trigger information']
|
76
|
+
]
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.return_value
|
80
|
+
"Returns a hash containing the updated trigger information."
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.authors
|
84
|
+
["crazymanish", "copilot"]
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.example_code
|
88
|
+
[
|
89
|
+
'circleci_update_trigger(
|
90
|
+
project_id: "01234567-89ab-cdef-0123-456789abcdef",
|
91
|
+
trigger_id: "fedcba98-7654-3210-fedc-ba9876543210",
|
92
|
+
description: "Updated webhook trigger description"
|
93
|
+
)',
|
94
|
+
'updated_trigger = circleci_update_trigger(
|
95
|
+
project_id: "01234567-89ab-cdef-0123-456789abcdef",
|
96
|
+
trigger_id: "fedcba98-7654-3210-fedc-ba9876543210",
|
97
|
+
description: "Updated GitHub PR Trigger",
|
98
|
+
config: {
|
99
|
+
"targetBranchMatchers" => ["main", "develop/*", "feature/*"]
|
100
|
+
}
|
101
|
+
)'
|
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
|