【问题标题】:BitBucket Pipeline - Build and deploy using node / gulp / git ftpBitBucket Pipeline - 使用 node / gulp / git ftp 构建和部署
【发布时间】:2017-12-18 09:23:23
【问题描述】:

我昨天注意到 BitBucket 支持 CICD 管道,这是我渴望使用的一项了不起的功能。

但是我在设置它时遇到了一些困难。

我的总体构建过程:

  • npm 安装
  • npm install -g bower
  • 凉亭安装
  • npm install -g gulp
  • 一饮而尽

gulp 命令正在构建 HTML 应用程序并将输出放置到 build 文件夹中。构建完成后,我希望将代码转移到我网站上的目录中。

这转换为以下bitbucket.yml

# This is a sample build configuration for JavaScript.
# Check our guides at https://confluence.atlassian.com/x/14UWN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: node:6.9.4

pipelines:
  default:
    - step:
        caches:
          - node
        script: # Modify the commands below to build your repository.
          - npm install
          - npm install -g bower
          - bower install --allow-root
          - npm install -g gulp
          - gulp
          - cd build
          - apt-get update
          - apt-get -qq install git-ftp
          - git ftp init --user $FTP_USERNAME --passwd $FTP_PASSWORD ftp://mywebsite.com/public_html/mydirectory

我遇到的问题是git ftp init 似乎正在上传src 文件夹,而不是在gulp 步骤期间创建的build 的内容。

有什么想法吗?


更新: --syncroot 似乎是部分修复。这意味着它现在确实尝试上传build 目录。但是,此时的问题是git ftp 似乎只是在同步跟踪的文件。

由于build 文件夹中的文件是在管道构建期间创建的,因此不适用于这些文件。

我尝试添加一个名为.git-ftp-include 的文件,如上所述,它应该传输未跟踪的文件。遗憾的是,我没有成功部署我的代码。

.git-ftp-include 文件内容: build/index.html:/src/index.html

这基本上是说:每当src 目录中的index.html 更改时,从build 同步根上传index.html

【问题讨论】:

    标签: node.js git ftp bitbucket bitbucket-pipelines


    【解决方案1】:

    在这种情况下,我建议您使用ncftp。在管道中将是这样的:

    - apt-get -qq install ncftp
    - ncftpput -v -u "$FTP_USERNAME" -p "$FTP_PASSWORD" -R $FTP_HOST /remote build/*
    

    【讨论】:

      【解决方案2】:

      对于通过git-ftp 传输的未跟踪文件,.git-ftp-include 中的语法为!filename

      【讨论】:

      • 实际上是'!'意味着应始终上传文件。当您只想上传已更改的文件时,使用我使用的符号。另外,我已经尝试过“!”并没有成功。
      • 您找到解决此问题的方法了吗?
      猜你喜欢
      • 2017-10-17
      • 2017-02-21
      • 2018-06-09
      • 2018-04-29
      • 2018-04-06
      • 2012-10-25
      • 1970-01-01
      • 2016-11-08
      • 1970-01-01
      相关资源
      最近更新 更多