是否可以自动执行Gsutil登录? [英] Is it possible to automate Gsutil login?

查看:86
本文介绍了是否可以自动执行Gsutil登录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以自动将基于gsutil的文件上传到Google云存储,以便登录时不需要用户干预?

Is it possible to automate gsutil based file upload to google cloud store so that the user intervention is not required for login?

我的用例是拥有一个詹金斯工作,该工作将轮询SCM位置以查找对一组文件的更改.如果检测到任何更改,它将把所有文件上传到特定的Google Cloud Store存储桶.

My usecase is to have a jenkins job which polls a SCM location for changes to a set of files. If it detects any changes it will upload all files to a specific Google Cloud Store bucket.

推荐答案

配置完凭据后,gsutil不再需要任何干预.我怀疑您以用户X的身份运行gsutil configure,但詹金斯以用户Y的身份运行.因此,~jenkins/.boto不存在.如果将.boto文件放置在正确的位置,则应该一切就绪.

After you configure your credentials once gsutil requires no further intervention. I suspect that you ran gsutil configure as user X but Jenkins runs as user Y. As a result, ~jenkins/.boto does not exist. If you place the .boto file in the right location you should be all set.

另一种替代方法是使用多个.boto文件,然后告诉gsutil与BOTO_CONFIG环境变量一起使用哪个文件:

Another alternative is to use multiple .boto files and then tell gsutil which one to use with the BOTO_CONFIG environment variable:

gsutil config  # complete oauth flow
cp ~/.boto /path/to/existing.boto
# detect that we need to upload
BOTO_CONFIG=/path/to/existing.boto gsutil -m cp files gs://bucket

我经常使用此模式将gsutil用于多个帐户:

I frequently use this pattern to use gsutil with multiple accounts:

gsutil config  # complete oauth flow for user A
mv ~/.boto user-a.boto
gsutil config  # complete oauth flow for user B
mv ~/.boto user-b.boto
BOTO_CONFIG=user-a.boto gsutil cp a-file gs://a-bucket
BOTO_CONFIG=user-b.boto gsutil cp b-file gs//b-bucket

这篇关于是否可以自动执行Gsutil登录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆