title: BitBucket Pipeline - Build and deploy using node / gulp / git ftp
body: <p>I noticed yesterday that BitBucket supported CICD pipelines, which is an amazing feature I'm eager to use.</p>
  
  <p>I have however some difficulty setting it up.</p>
  
  <p>My building process in general:</p>
  
  <ul>
  <li>npm install </li>
  <li>npm install -g bower </li>
  <li>bower install </li>
  <li>npm install -g gulp</li>
  <li>gulp</li>
  </ul>
  
  <p>The gulp command is building the HTML application and places the output to a <code>build</code> folder. After the build has been completed, I'd like the code to be transfered to a directory on my website.</p>
  
  <p>This translates to the following <code>bitbucket.yml</code>:</p>
  
  <pre><code># 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
  </code></pre>
  
  <p>The issue I'm getting is that the <code>git ftp init</code> seems to be uploading the <code>src</code> folder, and not the contents of the <code>build</code> one which is created during the <code>gulp</code> step.</p>
  
  <p>Any ideas?</p>
  
  <hr>
  
  <p><strong>Update:</strong> <code>--syncroot</code> does seem to be a partial fix. Meaning it does try to upload the <code>build</code> directory now. However, the problem at this point is that <code>git ftp</code> only seems to be syncing tracked files.</p>
  
  <p>Because the files in the <code>build</code> folder are created during the pipeline build, that does not apply to those.</p>
  
  <p>I have tried to add a file named <code>.git-ftp-include</code>, which as described should transfer untracked files. Sadly, I haven't been successful in deploying my code.</p>
  
  <p><code>.git-ftp-include</code> file contents:
      build/index.html:/src/index.html</p>
  
  <p>Which basically says: upload <code>index.html</code> from the <code>build</code> syncroot whenever the <code>index.html</code> in the <code>src</code> directory is changed.</p>