简体   繁体   English

如何运行 grunt build 以使用 bitbucket 管道部署 Web 应用程序?

[英]How to run grunt build in order to deploy the web application with bitbucket pipeline?

I want to generate the web application in production mode (running grunt build) and push the generated files and folders from the dist/ folder on my webhost with bitbucket pipelines via git ftp.我想在生产模式下生成 Web 应用程序(运行 grunt build),并通过 git ftp 使用 bitbucket 管道从我的网络主机上的dist/文件夹推送生成的文件和文件夹。

Bitbucket web application structure Bitbucket Web 应用程序结构

app[dir]
tests[dir]
.gitignore
Gruntfile.js
bitbucket-pipelines.yml
bower.json
package.json
...

gitignore gitignore

/node_modules
/dist
/.tmp
/.sass-cache
/bower_components

# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db
log
node_modules
node

# Personal application yamls #
##############################
*bitbucket-pipelines.yml
src/main/resources/static/js/vendor
application-cat.yml
.tern-project
bitbucket-pipelines.yml
.idea/workspace.xml

bitbucket-pipelines.yml bitbucket-pipelines.yml

image: node:4.6.0

pipelines:
  default:
    - step:
      script: 
        - apt-get update
        - apt-get -qq install git-ftp
        - npm install
        - npm install -g grunt-cli
        - npm install -g grunt@0.4.5
        - npm install -g bower
        - bower install  --allow-root
        - grunt build
        - git ftp push --user $FTP_USERNAME --passwd $FTP_PASSWORD ftp://myDomain.com/public_html/folder/

Notice注意

If I run locally "grunt build" it will generate a folder in my root application name: dist (witch is OK !!).如果我在本地运行“grunt build”,它将在我的根应用程序名称中生成一个文件夹: dist (女巫没问题!!)。 If I run the bitbucket.pipelines.yml script (all with success), it will not generate any dist folder (witch is NOT OK !!).如果我运行 bitbucket.pipelines.yml 脚本(全部成功),它不会生成任何dist文件夹(女巫不正常!!)。

Conclusion结论

I ended up with pushing all repository on my webhost because I can't target any dist folder.我最终将所有存储库推送到我的网络主机上,因为我无法定位任何dist文件夹。 Any suggestions ?有什么建议 ?

We need to use .git-ftp-include file to include the untracked files.我们需要使用.git-ftp-include文件来包含未跟踪的文件。 if grunt build generates the build folder.如果 grunt build 生成build文件夹。 Then we need to add the following in .git-ftp-include to force the build folder in sync process.然后我们需要在 .git-ftp-include 中添加以下内容以强制同步过程中的构建文件夹。

!build/

Hope it will help希望它会有所帮助

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM