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.
Files changed (72) 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/actions/get_circle_ci_artifacts.rb +1 -1
  68. data/lib/fastlane/plugin/circle_ci/actions/get_circle_ci_build_status.rb +1 -1
  69. data/lib/fastlane/plugin/circle_ci/actions/trigger_circle_ci_job.rb +1 -1
  70. data/lib/fastlane/plugin/circle_ci/helper/circle_ci_helper.rb +106 -5
  71. data/lib/fastlane/plugin/circle_ci/version.rb +1 -1
  72. metadata +99 -7
@@ -0,0 +1,131 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/circle_ci_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ module SharedValues
7
+ CIRCLECI_JOB_TIMESERIES = :CIRCLECI_JOB_TIMESERIES
8
+ end
9
+
10
+ class CircleciGetJobTimeseriesAction < Action
11
+ def self.run(params)
12
+ UI.message("Getting job timeseries data via Insights API v2...")
13
+
14
+ api_token = params[:api_token]
15
+ project_slug = params[:project_slug]
16
+ workflow_name = params[:workflow_name]
17
+
18
+ # Build query parameters
19
+ query_params = {}
20
+ query_params["branch"] = params[:branch] if params[:branch]
21
+ query_params["granularity"] = params[:granularity] if params[:granularity]
22
+ query_params["start-date"] = params[:start_date] if params[:start_date]
23
+ query_params["end-date"] = params[:end_date] if params[:end_date]
24
+
25
+ # Make API request
26
+ result = Helper::CircleCiHelper.get_v2("insights/time-series/#{project_slug}/workflows/#{workflow_name}/jobs", api_token, query_params)
27
+
28
+ # Store values in lane context
29
+ Actions.lane_context[SharedValues::CIRCLECI_JOB_TIMESERIES] = result
30
+
31
+ UI.success("Successfully retrieved job timeseries data for workflow #{workflow_name}")
32
+
33
+ return result
34
+ end
35
+
36
+ def self.description
37
+ "Gets timeseries data for all jobs within a workflow using Insights API v2"
38
+ end
39
+
40
+ def self.details
41
+ "This action retrieves timeseries data for all jobs within a workflow using the CircleCI Insights API v2. Hourly granularity data is only retained for 48 hours while daily granularity data is retained for 90 days."
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: :project_slug,
56
+ env_name: "CIRCLE_CI_PROJECT_SLUG",
57
+ description: "Project slug in the form vcs-slug/org-name/repo-name",
58
+ is_string: true,
59
+ optional: false),
60
+ FastlaneCore::ConfigItem.new(key: :workflow_name,
61
+ description: "The name of the workflow",
62
+ is_string: true,
63
+ optional: false),
64
+ FastlaneCore::ConfigItem.new(key: :branch,
65
+ description: "The name of a branch to filter for",
66
+ is_string: true,
67
+ optional: true),
68
+ FastlaneCore::ConfigItem.new(key: :granularity,
69
+ description: "The granularity of timeseries data points (hourly, daily, etc.)",
70
+ is_string: true,
71
+ optional: true),
72
+ FastlaneCore::ConfigItem.new(key: :start_date,
73
+ description: "Include only executions that started at or after this date (format: YYYY-MM-DD)",
74
+ is_string: true,
75
+ optional: true),
76
+ FastlaneCore::ConfigItem.new(key: :end_date,
77
+ description: "Include only executions that started before this date (format: YYYY-MM-DD)",
78
+ is_string: true,
79
+ optional: true)
80
+ ]
81
+ end
82
+
83
+ def self.output
84
+ [
85
+ ['CIRCLECI_JOB_TIMESERIES', 'An array of timeseries data, one entry per job']
86
+ ]
87
+ end
88
+
89
+ def self.return_value
90
+ "Returns an array of timeseries data, one entry per job."
91
+ end
92
+
93
+ def self.authors
94
+ ["crazymanish", "copilot"]
95
+ end
96
+
97
+ def self.example_code
98
+ [
99
+ 'circleci_get_job_timeseries(
100
+ project_slug: "gh/MyOrg/my-project",
101
+ workflow_name: "build-and-test"
102
+ )',
103
+ 'timeseries_data = circleci_get_job_timeseries(
104
+ project_slug: "gh/MyOrg/my-project",
105
+ workflow_name: "build-and-test",
106
+ branch: "main",
107
+ granularity: "daily",
108
+ start_date: "2025-01-01",
109
+ end_date: "2025-04-29"
110
+ )
111
+
112
+ # Process the timeseries data
113
+ timeseries_data["items"].each do |job_data|
114
+ UI.message("Job: #{job_data["name"]}")
115
+ job_data["metrics"].each do |metric|
116
+ UI.message(" #{metric["timestamp"]}: #{metric["total_runs"]} runs, #{metric["success_rate"]}% success rate")
117
+ end
118
+ end'
119
+ ]
120
+ end
121
+
122
+ def self.is_supported?(platform)
123
+ true
124
+ end
125
+
126
+ def self.category
127
+ :ci
128
+ end
129
+ end
130
+ end
131
+ end
@@ -0,0 +1,100 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/circle_ci_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ module SharedValues
7
+ CIRCLECI_MY_PIPELINES = :CIRCLECI_MY_PIPELINES
8
+ end
9
+
10
+ class CircleciGetMyPipelinesAction < Action
11
+ def self.run(params)
12
+ UI.message("Getting recent CircleCI pipelines for current user 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}/pipeline/mine", api_token)
19
+
20
+ # Store values in lane context
21
+ Actions.lane_context[SharedValues::CIRCLECI_MY_PIPELINES] = result["items"]
22
+
23
+ UI.success("Successfully retrieved #{result["items"].count} recent pipelines for current user")
24
+
25
+ return result["items"]
26
+ end
27
+
28
+ def self.description
29
+ "Gets recent pipelines for the current user from CircleCI using API v2"
30
+ end
31
+
32
+ def self.details
33
+ "This action retrieves recent pipelines triggered by or associated with the current user from CircleCI 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
+ optional: false)
52
+ ]
53
+ end
54
+
55
+ def self.output
56
+ [
57
+ ['CIRCLECI_MY_PIPELINES', 'An array of pipeline data for the current user']
58
+ ]
59
+ end
60
+
61
+ def self.return_value
62
+ "Returns an array of pipeline data including IDs, numbers, states, and created timestamps."
63
+ end
64
+
65
+ def self.authors
66
+ ["crazymanish", "copilot"]
67
+ end
68
+
69
+ def self.example_code
70
+ [
71
+ 'circleci_get_my_pipelines(
72
+ project_slug: "github/myorg/myrepo"
73
+ )',
74
+ 'my_pipelines = circleci_get_my_pipelines(
75
+ project_slug: "github/myorg/myrepo"
76
+ )
77
+
78
+ # Print details of recent pipelines
79
+ my_pipelines.each do |pipeline|
80
+ puts "Pipeline ##{pipeline["number"]}: #{pipeline["state"]} (#{pipeline["created_at"]})"
81
+ end
82
+
83
+ # Find a successful pipeline
84
+ success_pipeline = my_pipelines.find { |p| p["state"] == "success" }
85
+ if success_pipeline
86
+ puts "Latest successful pipeline: ##{success_pipeline["number"]}"
87
+ end'
88
+ ]
89
+ end
90
+
91
+ def self.is_supported?(platform)
92
+ true
93
+ end
94
+
95
+ def self.category
96
+ :ci
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,113 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/circle_ci_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ module SharedValues
7
+ CIRCLECI_ORG_SUMMARY = :CIRCLECI_ORG_SUMMARY
8
+ end
9
+
10
+ class CircleciGetOrgSummaryAction < Action
11
+ def self.run(params)
12
+ UI.message("Getting organization summary metrics via Insights API v2...")
13
+
14
+ api_token = params[:api_token]
15
+ org_slug = params[:org_slug]
16
+
17
+ # Build query parameters
18
+ query_params = {}
19
+ query_params["reporting-window"] = params[:reporting_window] if params[:reporting_window]
20
+ query_params["project-names"] = params[:project_names].join(',') if params[:project_names]&.any?
21
+
22
+ # Make API request
23
+ result = Helper::CircleCiHelper.get_v2("insights/#{org_slug}/summary", api_token, query_params)
24
+
25
+ # Store values in lane context
26
+ Actions.lane_context[SharedValues::CIRCLECI_ORG_SUMMARY] = result
27
+
28
+ UI.success("Successfully retrieved summary metrics for organization #{org_slug}")
29
+
30
+ return result
31
+ end
32
+
33
+ def self.description
34
+ "Gets summary metrics with trends for an entire organization using Insights API v2"
35
+ end
36
+
37
+ def self.details
38
+ "This action retrieves aggregated summary metrics with trends for the entire organization and for each project belonging to the organization using the CircleCI Insights API v2."
39
+ end
40
+
41
+ def self.available_options
42
+ [
43
+ FastlaneCore::ConfigItem.new(key: :api_token,
44
+ env_name: "CIRCLE_CI_API_TOKEN",
45
+ description: "API Token for CircleCI API",
46
+ sensitive: true,
47
+ code_gen_sensitive: true,
48
+ is_string: true,
49
+ default_value: ENV["CIRCLE_CI_API_TOKEN"],
50
+ default_value_dynamic: true,
51
+ optional: false),
52
+ FastlaneCore::ConfigItem.new(key: :org_slug,
53
+ env_name: "CIRCLE_CI_ORG_SLUG",
54
+ description: "Organization slug (e.g., 'gh/MyOrg')",
55
+ is_string: true,
56
+ optional: false),
57
+ FastlaneCore::ConfigItem.new(key: :reporting_window,
58
+ description: "The time window used to calculate summary metrics (last-24-hours, last-7-days, last-90-days, etc.)",
59
+ is_string: true,
60
+ optional: true),
61
+ FastlaneCore::ConfigItem.new(key: :project_names,
62
+ description: "List of project names to include in summary metrics",
63
+ type: Array,
64
+ optional: true)
65
+ ]
66
+ end
67
+
68
+ def self.output
69
+ [
70
+ ['CIRCLECI_ORG_SUMMARY', 'A hash containing organization summary metrics with trends']
71
+ ]
72
+ end
73
+
74
+ def self.return_value
75
+ "Returns a hash containing organization summary metrics with trends."
76
+ end
77
+
78
+ def self.authors
79
+ ["crazymanish", "copilot"]
80
+ end
81
+
82
+ def self.example_code
83
+ [
84
+ 'circleci_get_org_summary(
85
+ org_slug: "gh/MyOrg"
86
+ )',
87
+ 'org_summary = circleci_get_org_summary(
88
+ org_slug: "gh/MyOrg",
89
+ reporting_window: "last-30-days",
90
+ project_names: ["project-1", "project-2"]
91
+ )
92
+
93
+ # Access the organization summary metrics
94
+ UI.message("Total Credits Used: #{org_summary["org_data"]["metrics"]["total_credits_used"]}")
95
+ UI.message("Total Workflows: #{org_summary["org_data"]["metrics"]["total_runs"]}")
96
+
97
+ # Access metrics for each project
98
+ org_summary["org_projects"].each do |project|
99
+ UI.message("Project: #{project["project_name"]}, Success Rate: #{project["metrics"]["success_rate"]}%")
100
+ end'
101
+ ]
102
+ end
103
+
104
+ def self.is_supported?(platform)
105
+ true
106
+ end
107
+
108
+ def self.category
109
+ :ci
110
+ end
111
+ end
112
+ end
113
+ 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_PIPELINE = :CIRCLECI_PIPELINE
8
+ end
9
+
10
+ class CircleciGetPipelineAction < Action
11
+ def self.run(params)
12
+ UI.message("Getting CircleCI pipeline via API v2...")
13
+
14
+ api_token = params[:api_token]
15
+ pipeline_id = params[:pipeline_id]
16
+
17
+ # Make API request
18
+ result = Helper::CircleCiHelper.get_v2("pipeline/#{pipeline_id}", api_token)
19
+
20
+ # Store values in lane context
21
+ Actions.lane_context[SharedValues::CIRCLECI_PIPELINE] = result
22
+
23
+ UI.success("Successfully retrieved pipeline #{pipeline_id}")
24
+
25
+ return result
26
+ end
27
+
28
+ def self.description
29
+ "Gets information about a CircleCI pipeline using API v2"
30
+ end
31
+
32
+ def self.details
33
+ "This action retrieves detailed information about a specific CircleCI pipeline using the CircleCI API v2, including state, created timestamp, trigger information, and VCS data."
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: :pipeline_id,
48
+ env_name: "CIRCLE_CI_PIPELINE_ID",
49
+ description: "The ID of the pipeline to get information for",
50
+ is_string: true,
51
+ optional: false)
52
+ ]
53
+ end
54
+
55
+ def self.output
56
+ [
57
+ ['CIRCLECI_PIPELINE', 'A hash containing the pipeline details']
58
+ ]
59
+ end
60
+
61
+ def self.return_value
62
+ "Returns a hash containing detailed pipeline information including state, created timestamp, trigger information, and VCS data."
63
+ end
64
+
65
+ def self.authors
66
+ ["crazymanish", "copilot"]
67
+ end
68
+
69
+ def self.example_code
70
+ [
71
+ 'circleci_get_pipeline(
72
+ pipeline_id: "pipeline-uuid"
73
+ )',
74
+ 'pipeline = circleci_get_pipeline(
75
+ pipeline_id: "pipeline-uuid"
76
+ )
77
+
78
+ # Print pipeline details
79
+ puts "Pipeline state: #{pipeline["state"]}"
80
+ puts "Created at: #{pipeline["created_at"]}"
81
+ puts "Trigger: #{pipeline["trigger"]["type"]}"
82
+
83
+ # Check if pipeline is for a specific branch
84
+ if pipeline["vcs"] && pipeline["vcs"]["branch"] == "main"
85
+ UI.important("This is a main branch pipeline!")
86
+ end
87
+
88
+ # Get workflows for this pipeline
89
+ workflows = circleci_get_pipeline_workflows(
90
+ pipeline_id: pipeline["id"]
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,105 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/circle_ci_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ module SharedValues
7
+ CIRCLECI_PIPELINE_BY_NUMBER = :CIRCLECI_PIPELINE_BY_NUMBER
8
+ end
9
+
10
+ class CircleciGetPipelineByNumberAction < Action
11
+ def self.run(params)
12
+ UI.message("Getting CircleCI pipeline by number via API v2...")
13
+
14
+ api_token = params[:api_token]
15
+ project_slug = params[:project_slug]
16
+ pipeline_number = params[:pipeline_number]
17
+
18
+ # Make API request
19
+ result = Helper::CircleCiHelper.get_v2("project/#{project_slug}/pipeline/#{pipeline_number}", api_token)
20
+
21
+ # Store values in lane context
22
+ Actions.lane_context[SharedValues::CIRCLECI_PIPELINE_BY_NUMBER] = result
23
+
24
+ UI.success("Successfully retrieved pipeline number #{pipeline_number} for project #{project_slug}")
25
+
26
+ return result
27
+ end
28
+
29
+ def self.description
30
+ "Gets a specific pipeline by number from CircleCI using API v2"
31
+ end
32
+
33
+ def self.details
34
+ "This action retrieves details about a specific pipeline by its number from CircleCI 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: :pipeline_number,
56
+ env_name: "CIRCLE_CI_PIPELINE_NUMBER",
57
+ description: "The number of the pipeline to retrieve",
58
+ is_string: false,
59
+ optional: false)
60
+ ]
61
+ end
62
+
63
+ def self.output
64
+ [
65
+ ['CIRCLECI_PIPELINE_BY_NUMBER', 'A hash containing the pipeline details']
66
+ ]
67
+ end
68
+
69
+ def self.return_value
70
+ "Returns a hash containing pipeline details including state, created timestamp, and trigger information."
71
+ end
72
+
73
+ def self.authors
74
+ ["crazymanish", "copilot"]
75
+ end
76
+
77
+ def self.example_code
78
+ [
79
+ 'circleci_get_pipeline_by_number(
80
+ project_slug: "github/myorg/myrepo",
81
+ pipeline_number: 123
82
+ )',
83
+ 'pipeline = circleci_get_pipeline_by_number(
84
+ project_slug: "github/myorg/myrepo",
85
+ pipeline_number: 123
86
+ )
87
+
88
+ if pipeline["state"] == "success"
89
+ puts "Pipeline #{pipeline["number"]} completed successfully at #{pipeline["created_at"]}"
90
+ else
91
+ puts "Pipeline #{pipeline["number"]} is in state: #{pipeline["state"]}"
92
+ end'
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,92 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/circle_ci_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ module SharedValues
7
+ CIRCLECI_PIPELINE_CONFIG = :CIRCLECI_PIPELINE_CONFIG
8
+ end
9
+
10
+ class CircleciGetPipelineConfigAction < Action
11
+ def self.run(params)
12
+ UI.message("Getting CircleCI pipeline configuration via API v2...")
13
+
14
+ api_token = params[:api_token]
15
+ pipeline_id = params[:pipeline_id]
16
+
17
+ # Make API request
18
+ result = Helper::CircleCiHelper.get_v2("pipeline/#{pipeline_id}/config", api_token)
19
+
20
+ # Store values in lane context
21
+ Actions.lane_context[SharedValues::CIRCLECI_PIPELINE_CONFIG] = result
22
+
23
+ UI.success("Successfully retrieved configuration for pipeline #{pipeline_id}")
24
+
25
+ return result
26
+ end
27
+
28
+ def self.description
29
+ "Gets the configuration for a CircleCI pipeline using API v2"
30
+ end
31
+
32
+ def self.details
33
+ "This action retrieves the configuration for a specific CircleCI pipeline using the CircleCI API v2. The configuration includes the source and compiled YAML configuration files."
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: :pipeline_id,
48
+ description: "The ID of the pipeline to retrieve configuration for",
49
+ is_string: true,
50
+ optional: false)
51
+ ]
52
+ end
53
+
54
+ def self.output
55
+ [
56
+ ['CIRCLECI_PIPELINE_CONFIG', 'A hash containing the pipeline configuration information']
57
+ ]
58
+ end
59
+
60
+ def self.return_value
61
+ "Returns a hash containing pipeline configuration information including source and compiled configurations."
62
+ end
63
+
64
+ def self.authors
65
+ ["crazymanish", "copilot"]
66
+ end
67
+
68
+ def self.example_code
69
+ [
70
+ 'circleci_get_pipeline_config(
71
+ pipeline_id: "01234567-89ab-cdef-0123-456789abcdef"
72
+ )',
73
+ 'config = circleci_get_pipeline_config(
74
+ pipeline_id: "01234567-89ab-cdef-0123-456789abcdef"
75
+ )
76
+
77
+ # Use the pipeline configuration information
78
+ UI.message("Source config: #{config["source"]}")
79
+ UI.message("Compiled config: #{config["compiled"]}")'
80
+ ]
81
+ end
82
+
83
+ def self.is_supported?(platform)
84
+ true
85
+ end
86
+
87
+ def self.category
88
+ :ci
89
+ end
90
+ end
91
+ end
92
+ end