job 'stage-3-demo' do
  description 'the third stage in the pipeline
designed to deploy a shared demo environment
only when all regression tests are passing'

  configure_common_items{}

  properties do
    parameters do
      upstream_parameter do
        upstream_job_name 'stage-1-dev'
        name 'APPLICATION_VERSION'
        description 'the version of the application to deploy and test'
      end

      upstream_parameter do
        upstream_job_name 'stage-1-dev'
        name 'APPLICATION_COMMIT_HASH'
        description 'the git commit hash paired with the application version (tip: choose the same list item index as the application version)'
      end
    end
  end

  scm do
    git do
      commit_hash '${APPLICATION_COMMIT_HASH}'
    end
  end

  assigned_node_string '<%= @slave_label %>'

  builders do
    bash do
      script '#!/usr/bin/env bash
set +xe

export PATH=/usr/local/sbin:/usr/local/bin:$PATH

export WORKSPACE_SETTING=aws_demo
source .ecosystem

rake deploy[$APPLICATION_VERSION]
'
    end
  end

  publishers do
    html do
      report_name 'Vagrant Logs'
      report_directory_path "path/to/vagrant/logs"
      index_file_name 'index.html'
    end
  end

end
