multipackage.external.travis module¶
Wrapper class for Travis CI API v3.
Reference¶
-
class
multipackage.external.travis.
TravisCI
(com_token=None, org_token=None)[source]¶ Bases:
object
Wrapper for Travis CI API v3.
This wrapper is not complete but currently just implements the features needed for multipackage including setting up a repository and encrypting data.
Note that repositories can run builds on either travis-ci.org or travis-ci.com. When encrypting environment variables, it’s required that the variable be encrypted with the public key for either .com or .org, otherwise the variable will not decrypt correctly.
You must have environment variables set for:
- TRAVIS_TOKEN_COM: Your travis-ci.com token
- TRAVIS_TOKEN_ORG: YOur travis-ci.org token
Parameters: - com_token (str) – Optional API token for travis-ci.com. If not specified it is read from the environment variables TRAVIS_TOKEN_COM. If the environment variable is not specified, an exception is raised.
- org_token (str) – Optional API token for travis-ci.org. If not specified it is read from the environment variables TRAVIS_TOKEN_ORG. If the environment variable is not specified, an exception is raised.
-
NO_ENV_REASON
= 'Needed to authenticate to the Travis CI API'¶
-
INVALID_REASON
= 'You have a token but it was rejected by Travis'¶
-
SUGGESTION_COM
= 'Your travis-ci.COM token is on the settings tab of your travis-ci profile: https://travis-ci.com/account/preferences'¶
-
SUGGESTION_ORG
= 'Your travis-ci.ORG token is on the settings tab of your travis-ci profile: https://travis-ci.org/account/preferences'¶
-
TRAVIS_BASE_ORG
= 'https://api.travis-ci.org'¶
-
TRAVIS_BASE_COM
= 'https://api.travis-ci.com'¶
-
get_info
(repo_slug)[source]¶ Get info about this repository on Travis CI.
Parameters: repo_slug (str) – The repository slug to set up. Returns: The repository info Return type: dict
-
use_travis_org
(repo_slug)[source]¶ Check and see if this repo is on travis.org or com.
Returns: True if on travis-ci.org, False if on travis-ci.com. Return type: bool
-
get_key
(repo_slug)[source]¶ Get the encryption key for a repository by its slug.
This method will automatically get the correct key for the repository whether it is running on travis-ci.com or travis-ci.org. It will only look up each key once using a global cache of keys.
-
encrypt_env
(repo_slug, *env_names, **kwargs)[source]¶ Encrypt one or more environment variables.
The resulting string is suitable for pasting directly into a .travis.yml file, i.e. it is of the form secure: <encrypted value>
See https://github.com/travis-ci/travis-ci/issues/9548 for why it could be necessary to include all secure environment variables in a single line.
If only value is passed as a keyword arg, you must give a single environment variable name and its raw value will be encrypted without a NAME= prefix.