在 Travis build/test 成功后,如何将 node.js 应用程序部署到私有服务器?
How can I deploy a node.js app to a private server after a successful Travis build/test?
这是我为我的 node.js 应用考虑的管道:
在开发机器上编写代码 -> 提交到 github -> Travis 构建和测试 -> 成功:部署到私有服务器
我正在寻找完成最后一部分的工具。
例如,某些工具会收到 Travis 的通知,并将代码从 github 提取到我的私人服务器(并以这种方式部署应用程序)。
You can easily deploy to your own server the way you would deploy from
your local machine by adding a custom after_success step.
You may choose the Script provider instead, as it provides easier
flexibility with conditional deployment.
FTP
env:
global:
- "FTP_USER=user"
- "FTP_PASSWORD=password"
after_success:
"curl --ftp-create-dirs -T uploadfilename -u $FTP_USER:$FTP_PASSWORD ftp://sitename.com/directory/myfile"
The env variables FTP_USER and FTP_PASSWORD can also be encrypted.
See curl(1) for more details on how to use cURL as an FTP client.
或Git
after_success:
- eval "$(ssh-agent -s)" #start the ssh agent
- chmod 600 .travis/deploy_key.pem # this key should have push access
- ssh-add .travis/deploy_key.pem
- git remote add deploy DEPLOY_REPO_URI_GOES_HERE
- git push deploy
See “How can I encrypt files that include sensitive data?” if you
don’t want to commit the private key unencrypted to your repository.
这是我为我的 node.js 应用考虑的管道:
在开发机器上编写代码 -> 提交到 github -> Travis 构建和测试 -> 成功:部署到私有服务器
我正在寻找完成最后一部分的工具。
例如,某些工具会收到 Travis 的通知,并将代码从 github 提取到我的私人服务器(并以这种方式部署应用程序)。
You can easily deploy to your own server the way you would deploy from your local machine by adding a custom after_success step.
You may choose the Script provider instead, as it provides easier flexibility with conditional deployment.
FTP
env:
global:
- "FTP_USER=user"
- "FTP_PASSWORD=password"
after_success:
"curl --ftp-create-dirs -T uploadfilename -u $FTP_USER:$FTP_PASSWORD ftp://sitename.com/directory/myfile"
The env variables FTP_USER and FTP_PASSWORD can also be encrypted.
See curl(1) for more details on how to use cURL as an FTP client.
或Git
after_success:
- eval "$(ssh-agent -s)" #start the ssh agent
- chmod 600 .travis/deploy_key.pem # this key should have push access
- ssh-add .travis/deploy_key.pem
- git remote add deploy DEPLOY_REPO_URI_GOES_HERE
- git push deploy
See “How can I encrypt files that include sensitive data?” if you don’t want to commit the private key unencrypted to your repository.