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.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +272 -3
  3. data/lib/fastlane/plugin/circle_ci/actions/circleci_add_context_env_var.rb +117 -0
  4. data/lib/fastlane/plugin/circle_ci/actions/circleci_add_project_collaborator.rb +109 -0
  5. data/lib/fastlane/plugin/circle_ci/actions/circleci_approve_job.rb +95 -0
  6. data/lib/fastlane/plugin/circle_ci/actions/circleci_cancel_job.rb +96 -0
  7. data/lib/fastlane/plugin/circle_ci/actions/circleci_cancel_workflow.rb +85 -0
  8. data/lib/fastlane/plugin/circle_ci/actions/circleci_continue_pipeline.rb +104 -0
  9. data/lib/fastlane/plugin/circle_ci/actions/circleci_create_checkout_key.rb +110 -0
  10. data/lib/fastlane/plugin/circle_ci/actions/circleci_create_pipeline_definition.rb +126 -0
  11. data/lib/fastlane/plugin/circle_ci/actions/circleci_create_pipeline_definition_trigger.rb +133 -0
  12. data/lib/fastlane/plugin/circle_ci/actions/circleci_create_pipeline_schedule.rb +160 -0
  13. data/lib/fastlane/plugin/circle_ci/actions/circleci_create_project.rb +105 -0
  14. data/lib/fastlane/plugin/circle_ci/actions/circleci_create_webhook.rb +155 -0
  15. data/lib/fastlane/plugin/circle_ci/actions/circleci_delete_checkout_key.rb +93 -0
  16. data/lib/fastlane/plugin/circle_ci/actions/circleci_delete_context_env_var.rb +110 -0
  17. data/lib/fastlane/plugin/circle_ci/actions/circleci_delete_env_var.rb +86 -0
  18. data/lib/fastlane/plugin/circle_ci/actions/circleci_delete_pipeline_definition.rb +91 -0
  19. data/lib/fastlane/plugin/circle_ci/actions/circleci_delete_pipeline_schedule.rb +95 -0
  20. data/lib/fastlane/plugin/circle_ci/actions/circleci_delete_trigger.rb +92 -0
  21. data/lib/fastlane/plugin/circle_ci/actions/circleci_delete_webhook.rb +86 -0
  22. data/lib/fastlane/plugin/circle_ci/actions/circleci_download_artifact.rb +119 -0
  23. data/lib/fastlane/plugin/circle_ci/actions/circleci_download_workflow_artifacts.rb +400 -0
  24. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_checkout_key.rb +101 -0
  25. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_checkout_keys.rb +96 -0
  26. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_context_env_vars.rb +114 -0
  27. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_env_vars.rb +95 -0
  28. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_flaky_tests.rb +99 -0
  29. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_job_artifacts.rb +111 -0
  30. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_job_details.rb +110 -0
  31. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_job_tests.rb +111 -0
  32. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_job_timeseries.rb +131 -0
  33. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_my_pipelines.rb +100 -0
  34. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_org_summary.rb +113 -0
  35. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_pipeline.rb +104 -0
  36. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_pipeline_by_number.rb +105 -0
  37. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_pipeline_config.rb +92 -0
  38. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_pipeline_definition.rb +99 -0
  39. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_pipeline_definitions.rb +94 -0
  40. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_pipeline_values.rb +91 -0
  41. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_pipeline_workflows.rb +108 -0
  42. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_project_branches.rb +105 -0
  43. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_project_config.rb +104 -0
  44. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_project_workflow_metrics.rb +121 -0
  45. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_trigger.rb +99 -0
  46. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_user_info.rb +83 -0
  47. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_workflow.rb +121 -0
  48. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_workflow_insights.rb +157 -0
  49. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_workflow_job_metrics.rb +123 -0
  50. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_workflow_jobs.rb +109 -0
  51. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_workflow_runs.rb +129 -0
  52. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_workflow_summary.rb +118 -0
  53. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_workflow_test_metrics.rb +115 -0
  54. data/lib/fastlane/plugin/circle_ci/actions/circleci_list_all_pipelines.rb +94 -0
  55. data/lib/fastlane/plugin/circle_ci/actions/circleci_list_contexts.rb +132 -0
  56. data/lib/fastlane/plugin/circle_ci/actions/circleci_list_pipeline_definition_triggers.rb +101 -0
  57. data/lib/fastlane/plugin/circle_ci/actions/circleci_list_pipeline_schedules.rb +99 -0
  58. data/lib/fastlane/plugin/circle_ci/actions/circleci_list_projects.rb +89 -0
  59. data/lib/fastlane/plugin/circle_ci/actions/circleci_list_webhooks.rb +111 -0
  60. data/lib/fastlane/plugin/circle_ci/actions/circleci_rerun_workflow.rb +101 -0
  61. data/lib/fastlane/plugin/circle_ci/actions/circleci_set_env_var.rb +102 -0
  62. data/lib/fastlane/plugin/circle_ci/actions/circleci_trigger_pipeline.rb +130 -0
  63. data/lib/fastlane/plugin/circle_ci/actions/circleci_update_pipeline_definition.rb +127 -0
  64. data/lib/fastlane/plugin/circle_ci/actions/circleci_update_pipeline_schedule.rb +134 -0
  65. data/lib/fastlane/plugin/circle_ci/actions/circleci_update_trigger.rb +114 -0
  66. data/lib/fastlane/plugin/circle_ci/actions/circleci_wait_for_pipeline.rb +152 -0
  67. data/lib/fastlane/plugin/circle_ci/helper/circle_ci_helper.rb +102 -1
  68. data/lib/fastlane/plugin/circle_ci/version.rb +1 -1
  69. metadata +99 -7
@@ -0,0 +1,96 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/circle_ci_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class CircleciCancelJobAction < Action
7
+ def self.run(params)
8
+ UI.message("Canceling CircleCI job via API v2...")
9
+
10
+ api_token = params[:api_token]
11
+ job_number = params[:job_number]
12
+ project_slug = params[:project_slug]
13
+
14
+ # Make API request with empty body as required by the API
15
+ result = Helper::CircleCiHelper.post_v2("project/#{project_slug}/job/#{job_number}/cancel", api_token, {})
16
+
17
+ UI.success("Successfully canceled job #{job_number} in project #{project_slug}")
18
+
19
+ return { success: true, message: result["message"] }
20
+ end
21
+
22
+ def self.description
23
+ "Cancels a running job in CircleCI using API v2"
24
+ end
25
+
26
+ def self.details
27
+ "This action cancels a specific running job in CircleCI using the CircleCI API v2. This provides more granular control than canceling an entire workflow."
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: :job_number,
49
+ env_name: "CIRCLE_CI_JOB_NUMBER",
50
+ description: "The number of the job to cancel",
51
+ is_string: true,
52
+ optional: false)
53
+ ]
54
+ end
55
+
56
+ def self.return_value
57
+ "Returns a hash with success status and the response message."
58
+ end
59
+
60
+ def self.authors
61
+ ["crazymanish", "copilot"]
62
+ end
63
+
64
+ def self.example_code
65
+ [
66
+ 'circleci_cancel_job(
67
+ project_slug: "github/myorg/myrepo",
68
+ job_number: "123"
69
+ )',
70
+ '# First get jobs for a workflow, then cancel a specific one
71
+ jobs = circleci_get_workflow_jobs(
72
+ workflow_id: "workflow-id"
73
+ )
74
+
75
+ # Find a job by name and cancel it if it\'s running
76
+ test_job = jobs.find { |job| job["name"] == "run-tests" && job["status"] == "running" }
77
+
78
+ if test_job
79
+ circleci_cancel_job(
80
+ project_slug: "github/myorg/myrepo",
81
+ job_number: test_job["job_number"]
82
+ )
83
+ end'
84
+ ]
85
+ end
86
+
87
+ def self.is_supported?(platform)
88
+ true
89
+ end
90
+
91
+ def self.category
92
+ :ci
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,85 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/circle_ci_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class CircleciCancelWorkflowAction < Action
7
+ def self.run(params)
8
+ UI.message("Canceling CircleCI workflow via API v2...")
9
+
10
+ api_token = params[:api_token]
11
+ workflow_id = params[:workflow_id]
12
+
13
+ # Make API request
14
+ result = Helper::CircleCiHelper.post_v2("workflow/#{workflow_id}/cancel", api_token)
15
+
16
+ UI.success("Successfully canceled workflow with ID #{workflow_id}")
17
+
18
+ return { success: true, message: result["message"] }
19
+ end
20
+
21
+ def self.description
22
+ "Cancels a running workflow in CircleCI using API v2"
23
+ end
24
+
25
+ def self.details
26
+ "This action cancels a specific running workflow in CircleCI using the CircleCI API v2."
27
+ end
28
+
29
+ def self.available_options
30
+ [
31
+ FastlaneCore::ConfigItem.new(key: :api_token,
32
+ env_name: "CIRCLE_CI_API_TOKEN",
33
+ description: "API Token for CircleCI API",
34
+ sensitive: true,
35
+ code_gen_sensitive: true,
36
+ is_string: true,
37
+ default_value: ENV["CIRCLE_CI_API_TOKEN"],
38
+ default_value_dynamic: true,
39
+ optional: false),
40
+ FastlaneCore::ConfigItem.new(key: :workflow_id,
41
+ env_name: "CIRCLE_CI_WORKFLOW_ID",
42
+ description: "The ID of the workflow to cancel",
43
+ is_string: true,
44
+ optional: false)
45
+ ]
46
+ end
47
+
48
+ def self.return_value
49
+ "Returns a hash with success status and the response message."
50
+ end
51
+
52
+ def self.authors
53
+ ["crazymanish", "copilot"]
54
+ end
55
+
56
+ def self.example_code
57
+ [
58
+ 'circleci_cancel_workflow(
59
+ workflow_id: "1234-5678-90ab-cdef"
60
+ )',
61
+ '# First get workflows for a pipeline, then cancel a specific one
62
+ workflows = circleci_get_pipeline_workflows(
63
+ pipeline_id: "some-pipeline-id"
64
+ )
65
+
66
+ workflows.each do |workflow|
67
+ if workflow["status"] == "running" && workflow["name"] == "build-and-test"
68
+ circleci_cancel_workflow(
69
+ workflow_id: workflow["id"]
70
+ )
71
+ end
72
+ end'
73
+ ]
74
+ end
75
+
76
+ def self.is_supported?(platform)
77
+ true
78
+ end
79
+
80
+ def self.category
81
+ :ci
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,104 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/circle_ci_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ module SharedValues
7
+ CIRCLECI_CONTINUED_PIPELINE = :CIRCLECI_CONTINUED_PIPELINE
8
+ end
9
+
10
+ class CircleciContinuePipelineAction < Action
11
+ def self.run(params)
12
+ UI.message("Continuing CircleCI pipeline via API v2...")
13
+
14
+ api_token = params[:api_token]
15
+ pipeline_id = params[:pipeline_id]
16
+ parameters = params[:parameters]
17
+
18
+ # Create the request body
19
+ body = {}
20
+ body["parameters"] = parameters if parameters
21
+
22
+ # Make API request
23
+ result = Helper::CircleCiHelper.post_v2("pipeline/continue", api_token, {
24
+ "pipeline-id" => pipeline_id,
25
+ "parameters" => parameters
26
+ })
27
+
28
+ # Store values in lane context
29
+ Actions.lane_context[SharedValues::CIRCLECI_CONTINUED_PIPELINE] = result
30
+
31
+ UI.success("Successfully continued pipeline with ID #{pipeline_id}")
32
+
33
+ return result
34
+ end
35
+
36
+ def self.description
37
+ "Continues a pipeline from the setup phase using CircleCI API v2"
38
+ end
39
+
40
+ def self.details
41
+ "This action continues a pipeline from the setup phase using the CircleCI API v2. This is useful for pipelines that require manual continuation or for dynamic configuration with parameters."
42
+ end
43
+
44
+ def self.available_options
45
+ [
46
+ FastlaneCore::ConfigItem.new(key: :api_token,
47
+ env_name: "CIRCLE_CI_API_TOKEN",
48
+ description: "API Token for CircleCI API",
49
+ sensitive: true,
50
+ code_gen_sensitive: true,
51
+ is_string: true,
52
+ default_value: ENV["CIRCLE_CI_API_TOKEN"],
53
+ default_value_dynamic: true,
54
+ optional: false),
55
+ FastlaneCore::ConfigItem.new(key: :pipeline_id,
56
+ description: "The ID of the pipeline to continue",
57
+ is_string: true,
58
+ optional: false),
59
+ FastlaneCore::ConfigItem.new(key: :parameters,
60
+ description: "Parameters to pass to the pipeline continuation (for dynamic config)",
61
+ type: Hash,
62
+ optional: true)
63
+ ]
64
+ end
65
+
66
+ def self.output
67
+ [
68
+ ['CIRCLECI_CONTINUED_PIPELINE', 'A hash containing the continued pipeline information']
69
+ ]
70
+ end
71
+
72
+ def self.return_value
73
+ "Returns a hash containing information about the continued pipeline."
74
+ end
75
+
76
+ def self.authors
77
+ ["crazymanish", "copilot"]
78
+ end
79
+
80
+ def self.example_code
81
+ [
82
+ 'circleci_continue_pipeline(
83
+ pipeline_id: "01234567-89ab-cdef-0123-456789abcdef"
84
+ )',
85
+ 'continued_pipeline = circleci_continue_pipeline(
86
+ pipeline_id: "01234567-89ab-cdef-0123-456789abcdef",
87
+ parameters: {
88
+ "deploy_env" => "staging",
89
+ "version" => "1.2.3"
90
+ }
91
+ )'
92
+ ]
93
+ end
94
+
95
+ def self.is_supported?(platform)
96
+ true
97
+ end
98
+
99
+ def self.category
100
+ :ci
101
+ end
102
+ end
103
+ end
104
+ 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_CHECKOUT_KEY = :CIRCLECI_CHECKOUT_KEY
8
+ end
9
+
10
+ class CircleciCreateCheckoutKeyAction < Action
11
+ def self.run(params)
12
+ UI.message("Creating CircleCI project checkout key via API v2...")
13
+
14
+ api_token = params[:api_token]
15
+ project_slug = params[:project_slug]
16
+ key_type = params[:key_type]
17
+
18
+ # Create the request body
19
+ body = {
20
+ "type" => key_type
21
+ }
22
+
23
+ # Make API request
24
+ result = Helper::CircleCiHelper.post_v2("project/#{project_slug}/checkout-key", api_token, body)
25
+
26
+ # Store values in lane context
27
+ Actions.lane_context[SharedValues::CIRCLECI_CHECKOUT_KEY] = result
28
+
29
+ UI.success("Successfully created checkout key (#{key_type}) for project #{project_slug}")
30
+
31
+ return result
32
+ end
33
+
34
+ def self.description
35
+ "Creates a new checkout key for a CircleCI project using API v2"
36
+ end
37
+
38
+ def self.details
39
+ "This action creates a new checkout key for a specific CircleCI project using the CircleCI API v2. Checkout keys are used to check out code from your version control system. You can create either a 'deploy-key' or a 'github-user-key'."
40
+ end
41
+
42
+ def self.available_options
43
+ [
44
+ FastlaneCore::ConfigItem.new(key: :api_token,
45
+ env_name: "CIRCLE_CI_API_TOKEN",
46
+ description: "API Token for CircleCI API",
47
+ sensitive: true,
48
+ code_gen_sensitive: true,
49
+ is_string: true,
50
+ default_value: ENV["CIRCLE_CI_API_TOKEN"],
51
+ default_value_dynamic: true,
52
+ optional: false),
53
+ FastlaneCore::ConfigItem.new(key: :project_slug,
54
+ env_name: "CIRCLE_CI_PROJECT_SLUG",
55
+ description: "Project slug in the form of :vcs-type/:org-name/:project-name (e.g. github/myorg/myrepo)",
56
+ is_string: true,
57
+ default_value: ENV["CIRCLE_CI_PROJECT_SLUG"],
58
+ default_value_dynamic: true,
59
+ optional: false),
60
+ FastlaneCore::ConfigItem.new(key: :key_type,
61
+ description: "The type of checkout key to create (deploy-key or github-user-key)",
62
+ is_string: true,
63
+ default_value: "deploy-key",
64
+ verify_block: proc do |value|
65
+ valid_types = ["deploy-key", "github-user-key"]
66
+ UI.user_error!("Key type must be one of: #{valid_types.join(', ')}") unless valid_types.include?(value)
67
+ end)
68
+ ]
69
+ end
70
+
71
+ def self.output
72
+ [
73
+ ['CIRCLECI_CHECKOUT_KEY', 'A hash containing the created checkout key information']
74
+ ]
75
+ end
76
+
77
+ def self.return_value
78
+ "Returns a hash containing the created checkout key information including type, fingerprint, and public key."
79
+ end
80
+
81
+ def self.authors
82
+ ["crazymanish", "copilot"]
83
+ end
84
+
85
+ def self.example_code
86
+ [
87
+ 'circleci_create_checkout_key(
88
+ project_slug: "gh/MyOrg/my-project",
89
+ key_type: "deploy-key"
90
+ )',
91
+ 'key = circleci_create_checkout_key(
92
+ project_slug: "gh/MyOrg/my-project",
93
+ key_type: "github-user-key"
94
+ )
95
+
96
+ # Use the created key information
97
+ UI.message("Created key fingerprint: #{key["fingerprint"]}")'
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,126 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/circle_ci_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ module SharedValues
7
+ CIRCLECI_CREATED_PIPELINE_DEFINITION = :CIRCLECI_CREATED_PIPELINE_DEFINITION
8
+ end
9
+
10
+ class CircleciCreatePipelineDefinitionAction < Action
11
+ def self.run(params)
12
+ UI.message("Creating CircleCI pipeline definition via API v2...")
13
+
14
+ api_token = params[:api_token]
15
+ project_id = params[:project_id]
16
+
17
+ # Build the request body
18
+ body = {
19
+ "name" => params[:name],
20
+ "config_source" => params[:config_source]
21
+ }
22
+ body["description"] = params[:description] if params[:description]
23
+
24
+ # Make API request
25
+ result = Helper::CircleCiHelper.post_v2("projects/#{project_id}/pipeline-definitions", api_token, body)
26
+
27
+ # Store values in lane context
28
+ Actions.lane_context[SharedValues::CIRCLECI_CREATED_PIPELINE_DEFINITION] = result
29
+
30
+ UI.success("Successfully created pipeline definition '#{params[:name]}' for project #{project_id}")
31
+
32
+ return result
33
+ end
34
+
35
+ def self.description
36
+ "Creates a pipeline definition for a CircleCI project using API v2"
37
+ end
38
+
39
+ def self.details
40
+ "This action creates a new pipeline definition for a specific CircleCI project using the CircleCI API v2. Pipeline definitions define how pipelines are configured for a project."
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: :name,
60
+ description: "The name of the pipeline definition",
61
+ is_string: true,
62
+ optional: false),
63
+ FastlaneCore::ConfigItem.new(key: :description,
64
+ description: "Optional description for the pipeline definition",
65
+ is_string: true,
66
+ optional: true),
67
+ FastlaneCore::ConfigItem.new(key: :config_source,
68
+ description: "Configuration source for the pipeline definition",
69
+ type: Hash,
70
+ optional: false,
71
+ verify_block: proc do |value|
72
+ UI.user_error!("config_source must contain 'provider'") unless value["provider"]
73
+ end)
74
+ ]
75
+ end
76
+
77
+ def self.output
78
+ [
79
+ ['CIRCLECI_CREATED_PIPELINE_DEFINITION', 'A hash containing the created pipeline definition information']
80
+ ]
81
+ end
82
+
83
+ def self.return_value
84
+ "Returns a hash containing the created pipeline definition information."
85
+ end
86
+
87
+ def self.authors
88
+ ["crazymanish", "copilot"]
89
+ end
90
+
91
+ def self.example_code
92
+ [
93
+ 'circleci_create_pipeline_definition(
94
+ project_id: "01234567-89ab-cdef-0123-456789abcdef",
95
+ name: "My Pipeline Definition",
96
+ description: "A pipeline definition for my project",
97
+ config_source: {
98
+ "provider" => "github_app",
99
+ "config_path" => ".circleci/config.yml"
100
+ }
101
+ )',
102
+ 'definition = circleci_create_pipeline_definition(
103
+ project_id: "01234567-89ab-cdef-0123-456789abcdef",
104
+ name: "Bitbucket Pipeline Definition",
105
+ config_source: {
106
+ "provider" => "bitbucket_dc",
107
+ "config_path" => ".circleci/config.yml",
108
+ "branch" => "main"
109
+ }
110
+ )
111
+
112
+ # Use the created pipeline definition
113
+ UI.message("Created definition ID: #{definition["id"]}")'
114
+ ]
115
+ end
116
+
117
+ def self.is_supported?(platform)
118
+ true
119
+ end
120
+
121
+ def self.category
122
+ :ci
123
+ end
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,133 @@
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_TRIGGER = :CIRCLECI_PIPELINE_DEFINITION_TRIGGER
8
+ end
9
+
10
+ class CircleciCreatePipelineDefinitionTriggerAction < Action
11
+ def self.run(params)
12
+ UI.message("Creating CircleCI pipeline definition trigger 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
+ trigger_type = params[:trigger_type]
18
+ description = params[:description]
19
+ config = params[:config]
20
+
21
+ # Create the request body
22
+ body = {
23
+ "type" => trigger_type,
24
+ "description" => description,
25
+ "config" => config
26
+ }
27
+
28
+ # Make API request
29
+ result = Helper::CircleCiHelper.post_v2("projects/#{project_id}/pipeline-definitions/#{pipeline_definition_id}/triggers", api_token, body)
30
+
31
+ # Store values in lane context
32
+ Actions.lane_context[SharedValues::CIRCLECI_PIPELINE_DEFINITION_TRIGGER] = result
33
+
34
+ UI.success("Successfully created pipeline definition trigger")
35
+
36
+ return result
37
+ end
38
+
39
+ def self.description
40
+ "Creates a trigger for a pipeline definition using CircleCI API v2"
41
+ end
42
+
43
+ def self.details
44
+ "This action creates a new trigger for a specific pipeline definition using the CircleCI API v2. Triggers allow you to automatically start pipelines based on events."
45
+ end
46
+
47
+ def self.available_options
48
+ [
49
+ FastlaneCore::ConfigItem.new(key: :api_token,
50
+ env_name: "CIRCLE_CI_API_TOKEN",
51
+ description: "API Token for CircleCI API",
52
+ sensitive: true,
53
+ code_gen_sensitive: true,
54
+ is_string: true,
55
+ default_value: ENV["CIRCLE_CI_API_TOKEN"],
56
+ default_value_dynamic: true,
57
+ optional: false),
58
+ FastlaneCore::ConfigItem.new(key: :project_id,
59
+ env_name: "CIRCLE_CI_PROJECT_ID",
60
+ description: "The ID of the CircleCI project",
61
+ is_string: true,
62
+ optional: false),
63
+ FastlaneCore::ConfigItem.new(key: :pipeline_definition_id,
64
+ description: "The ID of the pipeline definition",
65
+ is_string: true,
66
+ optional: false),
67
+ FastlaneCore::ConfigItem.new(key: :trigger_type,
68
+ description: "The type of trigger to create (e.g., 'webhook', 'github', etc.)",
69
+ is_string: true,
70
+ optional: false),
71
+ FastlaneCore::ConfigItem.new(key: :description,
72
+ description: "A description for the trigger",
73
+ is_string: true,
74
+ optional: true,
75
+ default_value: ""),
76
+ FastlaneCore::ConfigItem.new(key: :config,
77
+ description: "Configuration for the trigger (varies by trigger type)",
78
+ type: Hash,
79
+ optional: false)
80
+ ]
81
+ end
82
+
83
+ def self.output
84
+ [
85
+ ['CIRCLECI_PIPELINE_DEFINITION_TRIGGER', 'A hash containing the created trigger information']
86
+ ]
87
+ end
88
+
89
+ def self.return_value
90
+ "Returns a hash containing the created trigger information."
91
+ end
92
+
93
+ def self.authors
94
+ ["crazymanish", "copilot"]
95
+ end
96
+
97
+ def self.example_code
98
+ [
99
+ 'circleci_create_pipeline_definition_trigger(
100
+ project_id: "01234567-89ab-cdef-0123-456789abcdef",
101
+ pipeline_definition_id: "fedcba98-7654-3210-fedc-ba9876543210",
102
+ trigger_type: "webhook",
103
+ description: "My webhook trigger",
104
+ config: {
105
+ "authType" => "NONE"
106
+ }
107
+ )',
108
+ 'trigger = circleci_create_pipeline_definition_trigger(
109
+ project_id: "01234567-89ab-cdef-0123-456789abcdef",
110
+ pipeline_definition_id: "fedcba98-7654-3210-fedc-ba9876543210",
111
+ trigger_type: "github",
112
+ description: "GitHub Push Trigger",
113
+ config: {
114
+ "pushEventType" => "BRANCHES",
115
+ "targetBranchMatchers" => ["main", "develop/*"]
116
+ }
117
+ )
118
+
119
+ # Use the created trigger information
120
+ UI.message("Created trigger ID: #{trigger["id"]}")'
121
+ ]
122
+ end
123
+
124
+ def self.is_supported?(platform)
125
+ true
126
+ end
127
+
128
+ def self.category
129
+ :ci
130
+ end
131
+ end
132
+ end
133
+ end