Can I make ALIAS for Travis YAML configuration command? … “travis encrypt GITHUB_TOKEN=****** --add”?

好久不见. 提交于 2019-12-11 06:18:19

问题


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_TOKENand 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 the GITHUB_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?


回答1:


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.



来源:https://stackoverflow.com/questions/41133801/can-i-make-alias-for-travis-yaml-configuration-command-travis-encrypt-gith

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!