使用管道将文件夹从Bitbucket存储库推送到公共服务器
我在Bitbucket存储库中启用了管道,我需要运行Angular 2构建并在每次构建后在我的服务器中部署dist文件夹(在执行build命令后创建).
I have pipelines enabled in my Bitbucket repository and I need to run Angular 2 build and deploy the dist folder (which gets created after the build command is executed) in my server after every build.
我的bitbucket-pipelines.yml文件中包含以下内容:
I have following in my bitbucket-pipelines.yml file:
image: node:4.6.0
pipelines:
default:
- step:
script: # Modify the commands below to build your repository.
- npm install
- npm run build:prod
我在Internet上找到了以下代码段:
I found this code snippet on the Internet:
- apt-get update
- apt-get -qq install git-ftp
- git ftp push --user $FTP_USERNAME --passwd $FTP_PASSWORD ftp://123.456.789.123/timount/angular_app
我使用pem文件通过SSH客户端登录到服务器.那么上面的代码片段有用吗?如果没有,如何在上述命令中使用pem文件?
I use a pem file to login to my server through the SSH client. So is the above code snippet useful? If not, how can I use the pem file in the above command?
为更清楚起见,npm run build:prod
命令实际上创建了dist文件夹,该文件夹需要部署在上述位置的服务器上.我该如何实现?
To make it more clear, npm run build:prod
command actually creates the dist folder, which needs to be deployed on the server at the above location. How can I achieve this?
1.将此写入bitbucket-pipelines.yml
image: node:8.7.0
pipelines:
default:
- step:
name: Installation
caches:
- node
script:
- npm install
- step:
name: Building
script:
- npm install -g @angular/cli #need to install angular-cli to make build
- npm run build --aot
- step:
name: Deployment
script:
- apt-get update
- apt-get install ncftp
- ncftpput -v -u "$FTP_USERNAME" -p "$FTP_PASSWORD" -R $FTP_HOST $FTP_SITE_ROOT dist/*
- echo Finished uploading /dist files to $FTP_HOST$FTP_SITE_ROOT
2.配置您的bitbucket环境变量