我们正在尝试使用Bitbucket Pipelines将基本角度应用程序部署到Google Cloud上的VM,但不确定如何使用SSH密钥连接到服务器以复制构建文件。寻找例子但找不到。
我们能够使用Putty / SSH命令手动复制dist文件。
我们拥有Google Cloud VM的公钥/私钥,并将其添加到Bitbucket Pipelines> SSH Keys
我们的YML脚本如下:
image: node:6.9.4
pipelines:
default:
- step:
caches:
- node
script: # Modify the commands below to build your repository.
- npm install
- npm install -g @angular/[email protected]
- ng build --prod
- cd dist/
- ssh -i ???
正如@Chris所说,that article是正确的起点。步骤是:
ssh-keygen
在BitBucket中添加SSH密钥cat ~/.ssh/my_ssh_key.pub | ssh username@remote_host "mkdir -p ~/.ssh && touch ~/.ssh/authorized_keys && chmod -R go= ~/.ssh && cat >> ~/.ssh/authorized_keys"
或通过
`ssh-copy-id -i my_ssh_key username@remote_host`
scp username@remote_host:/path/to/file /path/to/destination
相当肯定this tutorial可能会派上用场
我们能够解决这个问题如下:
image: node:8
pipelines:
default:
- step:
caches:
- node
script: # Modify the commands below to build your repository.
#- echo "$(ls -la)"
- npm install
- npm install -g @angular/cli
- ng build --prod
- echo "$(ls -la dist/)"
- scp -r dist/ [email protected]:/home/suren/temp