我在我的package.json依赖私人到位桶回购
{
"my-dependency": "git+ssh://git@bitbucket.org/something/my-dependency.git"
}
我跟着中给出的说明[1]和[2]和创建的我与公里加密SSH密钥。
我创建了一个自定义的cloudbuild.yaml
如下:
# Decrypt the file containing the key
steps:
- name: 'gcr.io/cloud-builders/gcloud'
args:
- kms
- decrypt
- --ciphertext-file=bitbucket_rsa.enc
- --plaintext-file=/root/.ssh/id_rsa
- --location=global
- --keyring=default
- --key=bitbucket-key
volumes:
- name: 'ssh'
path: /root/.ssh
# Set up git with key and domain
- name: 'gcr.io/cloud-builders/git'
entrypoint: 'bash'
args:
- '-c'
- |
chmod 600 /root/.ssh/id_rsa
cat <<EOF >/root/.ssh/config
Hostname bitbucket.org
IdentityFile /root/.ssh/id_rsa
EOF
mv known_hosts /root/.ssh/known_hosts
volumes:
- name: 'ssh'
path: /root/.ssh
# Install
- name: 'gcr.io/cloud-builders/yarn'
args: ['install']
volumes:
- name: 'ssh'
path: /root/.ssh
# Build
- name: "gcr.io/cloud-builders/yarn"
args: ["build"]
volumes:
- name: 'ssh'
path: /root/.ssh
# Deploy
- name: "gcr.io/cloud-builders/gcloud"
args: ["app", "deploy", "my-service.yaml"]
volumes:
- name: 'ssh'
path: /root/.ssh
当我运行它通过gcloud builds submit --config=cloudbuild.yaml
经过精细步骤#0〜#3跑,但由于第4步失败app deploy
触发另一个yarn install
不访问步骤#定义的SSH密钥0和#1:
Step #4: INFO rm_node_modules took 0 seconds
Step #4: INFO starting: yarn_install
Step #4: INFO yarn_install yarn install
Step #4: INFO `yarn_install` stdout:
Step #4: yarn install v1.9.4
Step #4: [1/5] Validating package.json...
Step #4: [2/5] Resolving packages...
Step #4: [3/5] Fetching packages...
Step #4: info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Step #4:
Step #4: INFO `yarn_install` had stderr output:
Step #4: error Command failed.
Step #4: Exit code: 128
Step #4: Command: git
Step #4: Arguments: ls-remote --tags --heads ssh://git@bitbucket.org/something/my-dependency.git
Step #4: Directory: /workspace
Step #4: Output:
Step #4: Host key verification failed.
Step #4: fatal: Could not read from remote repository.
Step #4:
Step #4: Please make sure you have the correct access rights
Step #4: and the repository exists.
Step #4:
Step #4: ERROR error: `yarn_install` returned code: 1
Step #4: INFO yarn_install took 11 seconds
Step #4: INFO build process for FTL image took 11 seconds
Step #4: INFO full build took 11 seconds
Step #4: ERROR `yarn_install` had stderr output:
Step #4: error Command failed.
谢谢您的帮助!
参考文献:
[1] https://cloud.google.com/cloud-build/docs/access-private-github-repos
[2] 链接库私人在packages.json在应用程序部署到gcloud