【问题标题】:automation script for git cmdsgit cmds 的自动化脚本
【发布时间】:2020-07-10 17:28:49
【问题描述】:

我正在尝试编写一个 bash 脚本,该脚本将自动执行我们在日常基础上执行的一些操作: 1.克隆不同的repos 2.检查一些特定的提交 3.编译 4.等

我的挑战是,我希望这个脚本被不同的用户使用,并且我不希望脚本提示每个 git cmd 的密码。 我想将用户名 + pwd 作为脚本的参数,然后 git clone https://username:pasword@gitlab.../repoName/usename/proj.git
但我总是收到“对等方重置 TCP 连接”的错误。 显然在没有内置用户名的情况下运行 ssh 命令或 https 命令对我来说很好

有什么想法吗?

【问题讨论】:

    标签: bash git automation


    【解决方案1】:

    如果您必须使用“https”而不是“ssh”,请尝试使用 expect 脚本。

    #!/usr/bin/expect -f
    spawn git pull
    expect "Username"
    send "put here your username\r"
    expect "Password"
    send "put here your password\r"
    interact
    

    您也可以在同一个脚本中使用 bash 和 expect。

    【讨论】:

    • 谢谢,你可以在我的问题中看到我正在尝试 https
    • 是的,所以使用期望脚本,例如“spawn git clone”https://gitlab.com/your/repository”,而不是在 url 中带有用户名和密码的 url - 这将执行脚本。
    猜你喜欢
    • 2018-04-30
    • 2015-03-23
    • 1970-01-01
    • 2018-02-11
    • 2013-08-16
    • 2016-12-02
    • 2013-01-16
    • 1970-01-01
    相关资源
    最近更新 更多