首页 文章

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

提问于
浏览
1

我想在 生产环境 模式下生成Web应用程序(运行grunt构建),并通过git ftp从我的webhost上的 dist/ 文件夹中使用bitbucket管道推送生成的文件和文件夹 .

Bitbucket web application structure

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

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

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

如果我在本地运行"grunt build",它将在我的根应用程序名称中生成一个文件夹: dist (女巫可以!) . 如果我运行bitbucket.pipelines.yml脚本(全部成功),它将不会生成任何 dist 文件夹(女巫不行!!) .

Conclusion

我最终在我的webhost上推送所有存储库,因为我无法定位任何dist文件夹 . 有什么建议 ?

1 回答

  • 1

    我们需要使用 .git-ftp-include 文件来包含未跟踪的文件 . 如果grunt build生成 build 文件夹 . 然后我们需要在.git-ftp-include中添加以下内容以强制构建文件夹处于同步过程中 .

    !build/
    

    希望它会有所帮助

相关问题