2013-03-19 63 views
3

是否有可能自动化基于gsutil的文件上传到谷歌云存储,以便用户干预不需要登录?是否可以自动化Gsutil登录?

我的用例是有一个詹金斯工作,轮询一个SCM位置的一组文件的变化。如果它检测到任何更改,它会将所有文件上传到特定的Google云端存储分区。

+0

你能详细说明你想要做什么吗?你有最终用户运行gsutil吗? – jterrace 2013-03-19 20:22:17

+0

@jterrace更新详情 – 2013-03-20 13:34:20

回答

8

一旦gsutil不需要进一步干预即可配置凭证。我怀疑你以用户X运行gsutil configure,但Jenkins以用户Y运行。因此,~jenkins/.boto不存在。如果您将.boto文件放在正确的位置,您应该全部设置。

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

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 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

+0

gsutil配置已弃用现在使用gcloud auth登录 – 2014-07-30 00:21:53

+3

gsutil config仍然是配置独立gsutil的正确方式,但gcloud auth登录是配置通过Google Cloud SDK分发的gsutil的正确方式 – 2015-11-24 18:51:17

相关问题