簡體   English   中英

BitBucket管道 - 使用node / gulp / git ftp構建和部署

[英]BitBucket Pipeline - Build and deploy using node / gulp / git ftp

昨天我注意到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應該傳輸未跟蹤的文件。 遺憾的是,我沒有成功部署我的代碼。

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

基本上說:每當src目錄中的index.html發生更改時,都會從build同步根中上傳index.html

對於要通過git-ftp傳輸的未跟蹤文件, .git-ftp-include的語法是!filename

在這種情況下,我建議您使用ncftp 在管道中將是這樣的:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM