This project is a fastlane plugin. To get started with fastlane-plugin-circle_ci
, add it to your project by running:
fastlane add_plugin circle_ci
A fastlane plugin for Circle CI. π
This plugin provides a set of actions that allow you to interact with CircleCI from your fastlane workflows. It supports both CircleCI API v1.1 (legacy) and API v2 (current).
The actions in this plugin were created and enhanced with the assistance of GitHub Copilot, working alongside human developers to provide a comprehensive set of CircleCI integrations for your fastlane workflows.
circleci_trigger_pipeline
: Triggers a new CircleCI pipelinecircleci_get_pipeline
: Gets details of a specific pipelinecircleci_get_pipeline_workflows
: Gets workflows for a pipelinecircleci_wait_for_pipeline
: Waits for a pipeline to completecircleci_continue_pipeline
: Continues a pipeline that is on holdcircleci_get_pipeline_by_number
: Gets a pipeline by its numbercircleci_get_pipeline_config
: Gets the configuration of a pipelinecircleci_get_my_pipelines
: Gets pipelines associated with the current usercircleci_get_pipeline_values
: Gets pipeline parameter values
circleci_get_workflow_jobs
: Gets jobs for a workflowcircleci_get_job_details
: Gets detailed information about a jobcircleci_get_job_artifacts
: Gets artifacts generated by a jobcircleci_download_artifact
: Downloads an artifact to a local pathcircleci_download_workflow_artifacts
: Downloads all artifacts from a specific workflowcircleci_approve_job
: Approves a pending approval job in a workflowcircleci_cancel_job
: Cancels a running jobcircleci_cancel_workflow
: Cancels a running workflowcircleci_get_job_tests
: Gets test metadata for a jobcircleci_get_job_timeseries
: Gets timeseries data for a job
circleci_get_env_vars
: Gets environment variables for a projectcircleci_set_env_var
: Sets an environment variable for a projectcircleci_delete_env_var
: Deletes an environment variable from a project
circleci_list_contexts
: Lists available contexts for an ownercircleci_get_context_env_vars
: Gets environment variables for a contextcircleci_add_context_env_var
: Adds an environment variable to a contextcircleci_delete_context_env_var
: Deletes an environment variable from a context
circleci_add_project_collaborator
: Adds a collaborator to a projectcircleci_create_project
: Creates a new CircleCI projectcircleci_get_project_branches
: Gets all branches for a projectcircleci_get_project_config
: Gets the configuration of a projectcircleci_get_project_workflow_metrics
: Gets workflow metrics for a project
circleci_create_pipeline_schedule
: Creates a pipeline schedulecircleci_list_pipeline_schedules
: Lists all pipeline schedules for a projectcircleci_delete_pipeline_schedule
: Deletes a pipeline schedule
circleci_create_webhook
: Creates a webhook for a projectcircleci_delete_webhook
: Deletes a webhook
circleci_create_pipeline_definition
: Creates a pipeline definitioncircleci_get_pipeline_definition
: Gets details of a pipeline definitioncircleci_get_pipeline_definitions
: Lists all pipeline definitionscircleci_delete_pipeline_definition
: Deletes a pipeline definitioncircleci_create_pipeline_definition_trigger
: Creates a pipeline definition triggercircleci_delete_trigger
: Deletes a pipeline triggercircleci_get_trigger
: Gets information about a pipeline trigger
circleci_create_checkout_key
: Creates a checkout key for a projectcircleci_get_checkout_key
: Gets details of a specific checkout keycircleci_get_checkout_keys
: Lists all checkout keys for a projectcircleci_delete_checkout_key
: Deletes a checkout key
circleci_get_flaky_tests
: Gets flaky tests information for a projectcircleci_get_workflow_insights
: Gets insights data for a workflowcircleci_get_workflow_job_metrics
: Gets metrics for jobs in a workflowcircleci_get_workflow_runs
: Gets recent runs of a workflowcircleci_get_workflow_summary
: Gets summary metrics for a workflowcircleci_get_org_summary
: Gets summary metrics for an organizationcircleci_get_user_info
: Gets information about the authenticated user
trigger_circle_ci_job
: Triggers a specific job in CircleCIget_circle_ci_build_status
: Gets the status of a CircleCI buildget_circle_ci_artifacts
: Gets artifacts from a CircleCI builddownload_circle_ci_artifact
: Downloads a CircleCI artifact
# Trigger a pipeline on the main branch
pipeline = circleci_trigger_pipeline(
project_slug: "github/myorg/myrepo",
branch: "main",
parameters: {
"deploy_env" => "staging",
"run_integration_tests" => true
}
)
# Wait for the pipeline to complete
result = circleci_wait_for_pipeline(
pipeline_id: pipeline["id"],
timeout: 1800, # 30 minutes
poll_interval: 30 # Check status every 30 seconds
)
if result[:status] == "success"
UI.success("Pipeline completed successfully!")
else
UI.error("Pipeline failed with status: #{result[:status]}")
end
# Set an environment variable
circleci_set_env_var(
project_slug: "github/myorg/myrepo",
name: "DEPLOY_KEY",
value: ENV["MY_DEPLOY_KEY"]
)
# Get all environment variables
env_vars = circleci_get_env_vars(
project_slug: "github/myorg/myrepo"
)
# Check if a variable exists
has_api_key = env_vars.any? { |var| var["name"] == "API_KEY" }
# List all contexts
contexts = circleci_list_contexts(
owner_slug: "github/myorg"
)
# Get a specific context by name
deploy_context = contexts.find { |ctx| ctx["name"] == "deploy-context" }
if deploy_context
# Add an environment variable to the context
circleci_add_context_env_var(
context_id: deploy_context["id"],
env_var_name: "RELEASE_TOKEN",
env_var_value: ENV["RELEASE_TOKEN"]
)
end
# Download only JSON files (default)
circleci_download_workflow_artifacts(
project_slug: "github/myorg/myrepo"
)
# Download only XML files
circleci_download_workflow_artifacts(
project_slug: "github/myorg/myrepo",
file_extensions: "xml"
)
# Download both JSON and XML files
circleci_download_workflow_artifacts(
project_slug: "github/myorg/myrepo",
file_extensions: ["json", "xml"]
)
# Download artifacts from a specific job only
circleci_download_workflow_artifacts(
project_slug: "github/myorg/myrepo",
job_name: "build"
)
# Download all artifacts from a specific workflow
artifacts_info = circleci_download_workflow_artifacts(
project_slug: "github/myorg/myrepo",
branch: "master",
workflow_name: "test",
destination_dir: "./artifacts"
)
# Check how many artifacts were downloaded
UI.message("Downloaded #{artifacts_info[:total_artifacts]} artifacts from #{artifacts_info[:workflow_name]} workflow")
# Process downloaded artifacts if needed
artifacts_info[:downloaded_artifacts].each do |job_artifacts|
job_name = job_artifacts[:job_name]
job_artifacts[:artifacts].each do |artifact|
path = artifact[:download_path]
# Process artifact files as needed
puts "Processing #{path} from job #{job_name}"
end
end
# Get artifacts from a job
artifacts = circleci_get_job_artifacts(
project_slug: "github/myorg/myrepo",
job_number: "123"
)
# Download a specific artifact
if artifacts.any?
test_results = artifacts.find { |a| a["path"].end_with?("test-results.xml") }
if test_results
circleci_download_artifact(
artifact_url: test_results["url"],
destination_path: "./test-results/circle-results.xml"
)
end
end
# Create a pipeline schedule to run nightly
circleci_create_pipeline_schedule(
project_slug: "github/myorg/myrepo",
name: "Nightly Build",
description: "Runs every night at midnight",
timetable: {
per_hour: 1,
hours_of_day: [0],
days_of_week: [1, 2, 3, 4, 5]
},
branch: "main",
parameters: {
"deploy_env" => "staging"
}
)
# List all schedules for a project
schedules = circleci_list_pipeline_schedules(
project_slug: "github/myorg/myrepo"
)
# Find a specific schedule by name
nightly_build = schedules.find { |schedule| schedule["name"] == "Nightly Build" }
# Get flaky tests for a project
flaky_tests = circleci_get_flaky_tests(
project_slug: "github/myorg/myrepo"
)
# Take action on flaky tests
if flaky_tests["most_failed_tests"].any?
UI.important("Found #{flaky_tests["most_failed_tests"].count} flaky tests that need attention")
flaky_tests["most_failed_tests"].each do |test|
puts " - #{test["test_name"]}: Failed #{test["times_flaked"]} times"
end
end
# Get workflow metrics
workflow_metrics = circleci_get_project_workflow_metrics(
project_slug: "github/myorg/myrepo",
branch: "main",
reporting_window: "last-30-days"
)
To run both the tests, and code style validation, run
rake
To automatically fix many of the styling issues, use
rubocop -a
For any other issues and feedback about this plugin, please submit it to this repository.
If you have trouble using plugins, check out the Plugins Troubleshooting guide.
For more information about how the fastlane
plugin system works, check out the Plugins documentation.
fastlane is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out fastlane.tools.