简体   繁体   English

无法在 Compute Engine 中克隆 Google Cloud Repository

[英]Can't clone Google Cloud Repository in Compute Engine

I'm trying to set up a Node project in Google Compute Engine, following this guide: https://cloud.google.com/nodejs/getting-started/getting-started-on-compute-engine我正在尝试按照本指南在 Google Compute Engine 中设置节点项目: https://cloud.google.com/nodejs/getting-started/getting-started-on-compute-engine

Everything runs fine on the startup script, until line 27:在启动脚本上一切正常,直到第 27 行:

git clone https://source.developers.google.com/p/${PROJECTID}/r/${REPOSITORY} /opt/app/new-repo

When script tries to clone the repo, I get a few errors in log:当脚本尝试克隆 repo 时,我在日志中收到一些错误:

INVALID_ARGUMENT: Request contains an invalid argument

message: "Invalid authentication credentials. Please generate a new identifier: https://source.developers.google.com/new-password"

fatal: unable to access 'https://source.developers.google.com/<path-to-repo>': The requested URL returned error: 400

What could be the cause of this error, and how can I fix it?此错误的原因可能是什么,我该如何解决? I've tried to research cloning authentication, but haven't found anything related to scripts.我试图研究克隆身份验证,但没有找到与脚本相关的任何内容。 I visited the new-password link, and tried to execute the gitcookie command in server, but it didn't help.我访问了新密码链接,并尝试在服务器中执行 gitcookie 命令,但没有帮助。

Startup script I use is exactly like in guide :我使用的启动脚本与指南中的完全一样:

set -v


# Talk to the metadata server to get the project id
PROJECTID=$(curl -s "http://metadata.google.internal/computeMetadata/v1/project/project-id" -H "Metadata-Flavor: Google")
REPOSITORY="new-repo"

# Install logging monitor. The monitor will automatically pick up logs sent to
# syslog.
curl -s "https://storage.googleapis.com/signals-agents/logging/google-fluentd-install.sh" | bash
service google-fluentd restart &

# Install dependencies from apt
apt-get update
apt-get install -yq ca-certificates git build-essential supervisor

# Install nodejs
mkdir /opt/nodejs
curl https://nodejs.org/dist/v8.12.0/node-v8.12.0-linux-x64.tar.gz | tar xvzf - -C /opt/nodejs --strip-components=1
ln -s /opt/nodejs/bin/node /usr/bin/node
ln -s /opt/nodejs/bin/npm /usr/bin/npm

# Get the application source code from the Google Cloud Repository.
# git requires $HOME and it's not set during the startup script.
export HOME=/root
git config --global credential.helper gcloud.sh
git clone https://source.developers.google.com/p/${PROJECTID}/r/${REPOSITORY} /opt/app/new-repo

# Install app dependencies
cd /opt/app/new-repo
npm install

# Create a nodeapp user. The application will run as this user.
useradd -m -d /home/nodeapp nodeapp
chown -R nodeapp:nodeapp /opt/app

# Configure supervisor to run the node app.
cat >/etc/supervisor/conf.d/node-app.conf << EOF
[program:nodeapp]
directory=/opt/app/new-repo
command=npm start
autostart=true
autorestart=true
user=nodeapp
environment=HOME="/home/nodeapp",USER="nodeapp",NODE_ENV="production"
stdout_logfile=syslog
stderr_logfile=syslog
EOF

supervisorctl reread
supervisorctl update

# Application should now be running under supervisor

I suspect this issue is due to the caller not having permissions to the repository, I recommend you to check the account you are using to run this command has the required permissions to interact with Source Repositories.我怀疑这个问题是由于调用者没有对存储库的权限,我建议您检查您用于运行此命令的帐户是否具有与源存储库交互所需的权限。

If missing, I would suggest adding the role roles/source.admin to your account, using these instructions , and then try to run the command again.如果缺少,我建议使用这些说明将角色角色/source.admin添加到您的帐户,然后尝试再次运行该命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法通过外部 IP (nodejs) 访问谷歌云计算引擎 VM - can't access google cloud compute engine VM through external IP (nodejs) 为Google Compute Engine设置Cloud 9 - Setup Cloud 9 for Google Compute Engine Google Cloud Compute Engine-Node.js无法正常工作 - Google Cloud Compute Engine - Nodejs not working Google Cloud Compute Engine API:直接使用setMetadata创建createVM - Google Cloud Compute Engine API: createVM directly with setMetadata Compute Engine:“无法访问此站点” - Compute Engine : "This site can’t be reached" 无法连接到Node.js的Google Compute Engine教程中的存储服务器 - Can't connect to the storage server in the Google Compute Engine Tutorial for Node.js Google Compute Engine API:无法从机器映像创建实例 - Google Compute Engine API : can't create instance from machine image 从GCP App Engine中的Google Cloud Repository安装NPM - NPM install from Google Cloud Repository in GCP App Engine 在Compute Engine上连接Redis时,Google Cloud App Engine标准环境节点JS连接超时 - Google Cloud App Engine Standard Environment Node JS connection timeout when connecting Redis on Compute Engine 来自 google 官方文档的 Google Cloud Speech to Text NodeJs 在 Google Compute Engine Linux 服务器上不起作用 - Google Cloud Speech to Text NodeJs that from google official document does not work on Google Compute Engine Linux Server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM