Run CumulusCI Headlessly¶
CumulusCI can be used to run continuous integration builds in your CI system.
This section outlines how to setup services and orgs that can be defined in a particular environment such that they will be recognized by CumulusCI.
If you’re working in GitHub Actions, you can take advantage of our GitHub Actions framework to streamline your setup process. You’ll need the information in this document only if you wish to use an alternate authorization strategy or configure additional services.
Register Environment Services¶
It is often the case that services you use for local development will differ from the services that you want to use in your build system. For example, developers will setup a GitHub service locally that is associated with their GitHub User, while an integration build may want to run as an integration user when interacting with GitHub. By providing environment variables with specific prefixes, CumulusCI can detect and register those services for use when running tasks and flows.
Name Environment Services¶
Environment variables that define CumulusCI services adhere to the following format:
CUMULUSCI_SERVICE_<service_type>[__service_name]
All services should start with the prefix CUMULUSCI_SERVICE_ followed
immediately by the service_type (for a full list of available services
run cci service list). Additionally, you have the option to provide a
unique name for your service by adding a double underscore (__)
followed by the name you wish to use. If a name is specified it is
prepended with “env-” to help establish that this service is coming
from the environment. If a name is not specified, a defualt name of
env is used for that service.
Here are some examples of environment variable names along with their corresponding service types and names:
CUMULUSCI_SERVICE_github–> Agithubservice that will have the default name ofenvCUMULUSCI_SERVICE_github__integration-user–> Agithubservice that will have the nameenv-integration-userCUMULUSCI_SERVICE_github_enterprise__enter-user–> Agithub_enterpriseservice that will have the nameenv-enter-userCUMULUSCI_SERVICE_connected_app–> Aconnected_appservice with the default name ofenvCUMULUSCI_SERVICE_connected_app__sandbox–> Aconnected_appservice with the nameenv-sandbox
By always prepending env to the names of services
specified by environment variables, it is easy to see which services are
currently set by environment variables and which are not.
Environment Service Config Values¶
The value of the environment variables (i.e. everything that comes after
the = character) are provided in the form of a JSON string. The
following shows an example that defines a github service via an
environment variable:
CUMULUSCI_SERVICE_github='{"username": "jdoe", "email": "jane.doe@some.biz", "token": "<personal_access_token>"}'
These values provide CumulusCI with the required attributes for a
particular service. The easiest way to find what attributes are needed
for a particular service is to look for your service under the services
tag in the CumulusCI standard
library
and provide values for all “attributes” listed under the desired
service. You can also use cci service info to get the values from a
service you’ve configured locally.
For example, if you’re looking to register a connected_app service,
then the attributes: callback_url, client_id, and client_secret
would need to be provided in the following format:
{"callback_url": "<callback_url>", "client_id": "<client_id>", "client_secret": "<client_secret>"}
The values
<callback_url>,<client_id>, and<client_secret>should all be replaced with actual values.
GitHub Enterprise Server considerations¶
The use of GitHub environment variables is supported when connecting to a repository a GitHub Enterprise Server.
The GitHubEnterprise client is selected automatically based on the repository configuration in the cumulusci.yml file. When the repo_url is NOT GitHub.com an attempt will be made to connect to the base domain in repo_url. The GitHub environemnt variables are then used to authorize.
If your use case requires dependencies on a different server, for example, upstream dependencies reside on GitHub.com but your project repository is stored on a GitHub Enterprise Server do not use GITHUB_TOKEN, instead configure services for GitHub.com and your GitHub Enterprise Server similarly to this example:
CUMULUSCI_SERVICE_github='{"username": "jdoe", "email": "jane.doe@some.biz", "token": "<personal_access_token>"}'
CUMULUSCI_SERVICE_github_enterprise`='{"username": "jdoe", "email": "jane.doe@some.biz", "server_domain":"git.some.biz", "token": "<enterprise_personal_access_token>"}'
When connecting to repositories on GitHub.com or GitHub Enterprise Server, the service configuration for authorization is selected automatically by matching the server_domain field to the repository domain. When a repository domain is github.com the github service will be used.
Register Persistent Orgs¶
Multiple Services of the Same Type¶
In rare cases a build may need to utilize multiple services of the same
type. To set a specific service as the default for subsequent
tasks/flows run the cci service default <service_type> <name> command.
You can run this command again to set a new default service to be used
for the given service type.