trigger:
  branches:
    include:
      - master
  paths:
    exclude:
      - README.md
      - .gitignore

pool:
  name: dps-build
  demands: java

steps:

- task: Maven@3
  displayName: "mvn install register-core"
  inputs:
    codeCoverageToolOption: JaCoCo
    goals: "clean install"
    mavenPomFile: 'register-core/pom.xml'
    options: '--settings ./configuration/settings.xml -DVSTS_FEED_TOKEN=$(VSTS_FEED_TOKEN)'
    testResultsFiles: '**/*/TEST-*.xml'

- task: Maven@3
  displayName: "mvn install register-gcp"
  inputs:
    codeCoverageToolOption: JaCoCo
    goals: "clean install"
    mavenPomFile: 'provider/register-gcp/pom.xml'
    options: '--settings ./configuration/settings.xml -DVSTS_FEED_TOKEN=$(VSTS_FEED_TOKEN)'
    testResultsFiles: '**/*/TEST-*.xml'

- task: ArchiveFiles@2
  displayName: 'Archive integration-tests'
  inputs:
    rootFolderOrFile: 'testing'
    archiveFile: '$(Build.ArtifactStagingDirectory)/integration-tests.zip'
    includeRootFolder: false

- bash: |
   # Apply deployment templates
   gomplate -f deploy.sh -o deploy.sh

   # Make all bash scripts executable
   chmod a+x deploy.sh
   chmod a+x private-deploy.sh
  workingDirectory: provider/register-gcp/scripts
  displayName: 'Bash Script'

- task: CopyFiles@2
  displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
  inputs:
    Contents: |
     provider/register-gcp/target/*spring-boot.jar
     provider/register-gcp/src/main/appengine/app.yaml
     provider/register-gcp/src/main/resources/application.properties
     provider/register-gcp/scripts/*
    TargetFolder: '$(build.artifactstagingdirectory)'
    flattenFolders: true

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'

- task: ShellScript@2
  displayName: 'Shell Script private-deploy'
  inputs:
    scriptPath: '$(build.artifactstagingdirectory)/private-deploy.sh'