加密用于Travis CI的密码。
travis-encrypt的Python项目详细描述
travis encrypt是一个python命令行应用程序,它提供了一种加密密码的简单方法 与travis ci一起使用的环境变量。所有密码和环境变量都使用pkcs1v15填充方案加密,因为它是travis ci支持的唯一填充。
安装
要安装travis encrypt,只需在终端窗口中运行以下命令:
$ pip install travis-encrypt
如果您希望从源安装,请在终端窗口中运行以下命令:
$ git clone https://github.com/mandeep/Travis-Encrypt.git $ cd Travis-Encrypt $ python setup.py install
travis encrypt将尝试安装加密软件包,但是该软件包需要 c和python的开发包。如果安装失败,请参阅加密 安装指南:https://cryptography.io/en/latest/installation/
用法
安装travis encrypt后,可以使用以下命令和参数调用命令行应用程序:
usage: travis-encrypt [options] github_username repository [path] positional arguments: github_username GitHub username that houses the repository repository Name of the repository whose password requires encryption path Path to the repository's .travis.yml file optional arguments: --help Show the help message and quit --deploy Encrypt a password for continuous deployment usage --env Encrypt an environment variable --clipboard copy the encrypted password to the clipboard --env-file PATH Path for a .env file containing variables to encrypt --private Use the travis-ci.com API endpoint for private repositories
当输入命令时,应用程序将发出提示,用户可以在其中输入 密码或环境变量。在这两种情况下,提示将打印“password:”。 一旦提示被应答,travis encrypt将把加密的密码打印到标准 输出。如果提供了.travis.yml的路径,则加密密码将写入 .travis.yml而不是打印到标准输出。
密码加密示例(输入时密码隐藏):
$ travis-encrypt mandeep Travis-Encrypt Password: Please add the following to your .travis.yml: secure: "oxTYla2fHNRRjD0akv1e..." (edited for brevity)
部署密码加密示例:
$ travis-encrypt --deploy mandeep Travis-Encrypt /home/user/.travis.yml Password: Encrypted password added to /home/user/.travis.yml
加密环境变量api_token=“abc123”的示例:
$ travis-encrypt --env mandeep Travis-Encrypt /home/user/.travis.yml Password: Encrypted password added to /home/user/.travis.yml
使用.env文件的示例:
$ travis-encrypt --env-file /home/user/my.env mandeep Travis-Encrypt /home/user/.travis.yml Encrypted variables from /home/user/my.env added to /home/user/.travis.yml