【发布时间】:2021-08-08 09:35:50
【问题描述】:
我正在运行一个 bash 脚本,它会自动克隆一个 git repo。在提供的 git repo 中进行更改,然后将这些更改推送到 github。现在,当我克隆 repo 时,它会询问我的用户名,但我没有知道如何在 bash 脚本中提供这些输入。为了获得特权,我把一些东西涂黑了。但我会向你解释其余的。我已经尝试过 git config 但它不起作用。有人可以帮我解决这个问题
#!/bin/bash
set -e
appName=$(echo xxxxx/xxxxx)
echo $appName
version=`echo "$BRANCH_NAME-$BUILD_NUMBER" | tr / -`
echo $version
imageName=$appName:$version
echo $imageName
git config --global user.name "xxxxxxxx"
git config --global user.email "xxxxxxxxxxx"
git config --global user.password "xxxxxxxxxxxxxx"
git clone https://github.com/xxxxx/xxxxx.git
cd qa-namespace/red/website-manager
sed -i "s|\(image[[:space:]]*:[[:space:]]*\)\(.*\)|\1'${imageName}'|" input deployment.yaml
git add .
git commit -m "changed name of the branch"
git push
【问题讨论】:
-
使用SSH key
-
始终使用
$()而不是反引号。 -
appName=$(echo xxxxx/xxxxx)最好写成appName=xxxx/xxxx -
请注意,标准 Git 的任何部分都不会使用或检查
user.password设置。 -
@WilliamPursell 感谢您的建议,但我的问题是 git
标签: linux bash git shell github