问题描述
我有一个来自Github的个人访问令牌,我在许多项目中使用。由于令牌具有对我所有资源的读/写能力,因此使用
问题
是否有可能使这个travis命令成为我可以使用的别名并且结束?
[alias]
git repo-encrypt =travis encrypt GITHUB_TOKEN = **** secret * *** --add
如果是,如何和在哪里?
添加别名的简单方法是运行此单行:
git config --global alias.repo-encrypt'!travis encrypt GITHUB_TOKEN = **** secret **** --add'
或者,您可以运行 git config --global --edit
来打开全局Git配置配置的文本编辑器(由git的core.editor配置值控制)。然后在文件中添加以下内容:
[alias]
repo-encrypt =!travis encrypt GITHUB_TOKEN = * *** secret **** --add
添加别名后,运行 git repo-encrypt
将执行Travis命令。为了将来参考,使用!
启动Git别名,使其执行命令就好像它是一个正常的shell,而不是简单地将别名追加到 git
命令。通常情况下
请参阅,以获取更多信息。
I have a Personal Access Token from Github that I use in many of my projects. Since the token has read/write ability for all my repos, it's important I use the Travis Command Line Tool to encrypt the GITHUB_TOKEN
and place it in my .travis.yml
as a secure variable:
travis encrypt GITHUB_TOKEN=****secret**** --add
The Problem
- The
GITHUB_TOKEN
value is a hard to remember string of random characters, so every time I need it I first have to go find it, and then copy n' paste it into git bash. - Whenever I use the
travis encrypt
method, it associates theGITHUB_TOKEN
with ONLY the repository I'm in.
Question
Is it possible to make this travis command an alias I can use over and over?
[alias]
git repo-encrypt = "travis encrypt GITHUB_TOKEN=****secret**** --add"
If so, how and where?
The simple way to add the alias would be to run this one-liner:
git config --global alias.repo-encrypt '!travis encrypt GITHUB_TOKEN=****secret**** --add'
Alternatively, you can run git config --global --edit
to open the global Git configuration in your configured text editor (controlled by the core.editor config value of Git). Then add the following to the file:
[alias]
repo-encrypt = "!travis encrypt GITHUB_TOKEN=****secret**** --add"
After you add the alias, running git repo-encrypt
will execute the Travis command. For future reference, starting a Git alias with a !
makes it execute the command as though it were a normal shell, instead of simply appending the alias onto the end of the git
command as it would normally.
See the Git SCM Book page on aliases for more information.
这篇关于可以使用ALIAS进行Travis YAML配置命令吗? ...“travis encrypt GITHUB_TOKEN = ****** --add”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!