gpt4 book ai didi

linux - 当我使用协作 github 存储库时,crontab 无法识别 github 用户名

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:05:08 25 4
gpt4 key购买 nike

我正在尝试安排从上游公司 github 存储库获取的每日更新 https://github.abc.de.fghu.com/teamname/reponame.git .我有一个 Python 文件可以完成所有这些事情:python 代码是:

fetchcmd = Popen('git fetch upstream'.split(), stdout = f, stderr=f)
while fetchcmd.poll() is None:
pass
fetchcmd = Popen('git checkout master'.split(), stdout = f, stderr=f)
while fetchcmd.poll() is None:
pass
fetchcmd = Popen('git merge upstream/master'.split(), stdout = f, stderr=f)
while fetchcmd.poll() is None:
pass

cpcmd = Popen('cp -rf PATH_FILE .'.split(), stdout=f, stderr=f)
while cpcmd.poll() is None:
pass

pusharr = ['git add .', 'git commit -m"auto night push"', 'git push origin master']

for i in pusharr:
p = Popen(shlex.split(i), stdout = f, stderr=f)
while p.poll() is None:
pass

当我手动运行它时,它工作正常,但是,当我通过 crontab 安排它时,它给了我这个错误:

fatal: could not read Username for https://github.abc.de.fghu.com/': Device not configured

这里失败了:

fetchcmd = Popen('git fetch upstream'.split(), stdout = f, stderr=f)

但推送部分仍然成功,我从上游获取:

https://github.abc.de.fghu.com/teamname/reponame.git

并推送到我们的组 repo,它实际上是一个带有上面 url 的分支:

https://github.abc.de.fghu.com/our_tiny_group/reponame.git

最佳答案

could not read Username for https://github.abc.de.fghu.com/

检查在本地运行时是否设置了凭证助手:

git config credential.helper

由于该助手依赖于用户,crontab 进程可能无法访问它,考虑到它可能以 root 用户或其他用户身份运行。

OP Jialiang Zhou确认 in the comments :

the git config credential.helper gives me out put as oskeychain, and I think the crontab process it as a root

在这种情况下,as described here ,您需要编辑您的 crontab:

sudo crontab -u <yourLogin> -e

这样,作业将像您一样执行并访问相同的缓存凭据。

关于linux - 当我使用协作 github 存储库时,crontab 无法识别 github 用户名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48493096/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com