par*_*th6 1 windows git batch-file jenkins credential-manager
我有2个GIT储存库副本,我们称它们为“ origin”和“ backup”。我要实现的目标如下。我的团队不断推动并将其更改同步到“起源”,但是我想确保我在不同的地理位置拥有一份“起源”副本,以备重复之用,以防万一发生大火摧毁我办公室里的一切。为了实现这一目标,我将相同的git repo副本保留在云上。
现在,结合使用Jenkins和Windows批处理脚本,我试图找出一种使这些存储库保持同步的方式。批处理脚本将负责实际的同步操作,Jenkins将确保同步操作定期运行。重复的副本称为“备份”(您可能已经猜到了)。
问题是,当我直接从命令提示符运行批处理脚本时,它会完全按照我希望的方式执行;但是,当我尝试通过Jenkins作业执行批处理脚本时,它一直在等待“备份”存储库的用户名和密码。“备份”存储库的凭据已经存储在Windows凭据管理器中,并且批处理脚本在直接执行时可以使用凭据,但是以某种方式,当我尝试通过Jenkins执行时,情况并非如此。
我尝试了谷歌搜索,甚至还进行了大量搜索以查看是否可以在詹金斯论坛上找到一些东西,但是到目前为止,我还没有发现任何有用的东西。
我不确定这是否有用,但是下面是我的批处理脚本供参考。
@echo OFF
pushd K:
pushd "K:\my-git-workspace\mygit-repo"
echo Pulling "master" from origin
git pull origin master
echo Pulling "master" from backup
git pull backup master
echo Pushing "master" to backup
git push backup master
echo Pushing "master" to origin
git push origin master
echo Pulling all tags from origin
git pull --tags origin
echo Pulling all tags from backup
git pull --tags origin
echo Pushing all tags to backup
git push --tags backup
echo Pushing all tags to origin
git push --tags origin
popd
Run Code Online (Sandbox Code Playgroud)
这是我在Windows命令提示符下看到的GIT配置(我已经用虚拟值替换了user.name和user.email)
core.symlinks=false
core.autocrlf=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
pack.packsizelimit=2g
help.format=html
http.sslcainfo=/bin/curl-ca-bundle.crt
sendemail.smtpserver=/bin/msmtp.exe
diff.astextplain.textconv=astextplain
rebase.autosquash=true
user.email=myemail@domain.com
user.name=My Name
credential.helper=wincred
Run Code Online (Sandbox Code Playgroud)
这是我从詹金斯运行时获得的GIT配置(git config -l)
core.symlinks=false
core.autocrlf=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
pack.packsizelimit=2g
help.format=html
http.sslcainfo=/bin/curl-ca-bundle.crt
sendemail.smtpserver=/bin/msmtp.exe
diff.astextplain.textconv=astextplain
rebase.autosquash=true
user.email=myemail@domain.com
user.name=My Name
credential.helper=wincred
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
core.hidedotfiles=dotGitOnly
remote.origin.url=//networkrepo/git/repo
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
remote.backup.url=http://cloud-hosted-git-repo/repo.git
remote.backup.fetch=+refs/heads/*:refs/remotes/backup/*
gui.wmstate=zoomed
gui.geometry=584x210+321+316 304 192
credential.helper=store
user.email=myemail@domain.com
user.name=My Name
Run Code Online (Sandbox Code Playgroud)
不用说,任何帮助将不胜感激。
干杯。
终于找到了解决方案。感谢David Ruhmann。正如David在对该问题的评论中提到的解决方案,是转到Windows服务管理器并将“登录身份”列的值从“本地系统”更改为您要用来从中运行批处理脚本的Windows帐户。命令提示符。在我的情况下,由于Windows的登录用户称为“ BOB”,因此将本地系统值更改为BOB并在服务管理器中为此用户指定登录密码就可以了。
要记住的另一件事是:为了使更改生效,您必须重新启动Jenkins服务。
归档时间: |
|
查看次数: |
3256 次 |
最近记录: |