image: node:lts

definitions:
  steps:
    - step: &build-step
        name: SonarQube analysis
        script:
          - pipe: sonarsource/sonarqube-scan:1.1.0
            variables:
              SONAR_HOST_URL: ${SONAR_HOST_URL} # Get the value from the repository/workspace variable.
              SONAR_TOKEN: ${SONAR_TOKEN} # Get the value from the repository/workspace variable. You shouldn't set secret in clear text here.
  caches:
    sonar: ~/.sonar

clone:
  depth: full

pipelines:
  default: # Pipelines that are triggered manually via the Bitbucket GUI
    - step:
        name: Build
        script:
          - yarn
          - yarn build
        artifacts: # defining build/ as an artifact
          - build/**
    - step:
        name: Deploy
        script:
          - apt-get update
          - apt-get install ncftp
          - ncftpput -v -u "$FTP_USERNAME" -p "$FTP_PASSWORD" -R $FTP_HOST $FTP_SITE_ROOT_DEV build/*
          - echo Finished uploading /build files to $FTP_HOST$FTP_SITE_ROOT